Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Some string exercises
(1)
Write a small program that uses "string.format() to print a greeting card message to all the following people:
Toshio
Andrew
Rodolfo
(2)
Here is a snippet from a log file:
log_message = """
Oct 9 00:00:51 camelback systemd[7500]: Starting audit...
Oct 9 00:00:18 camelback systemd[1]: logrotate.service: Deactivated successfully.
Oct 9 00:00:18 camelback systemd[1]: Finished Rotate log files.
Oct 9 00:00:18 camelback audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=logrotate comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Oct 9 00:00:18 camelback audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=logrotate comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Oct 9 00:00:18 camelback audit: BPF prog-id=0 op=UNLOAD
Oct 9 00:00:19 camelback systemd[1]: mlocate-updatedb.service: Deactivated successfully.
Oct 9 00:00:19 camelback systemd[1]: mlocate-updatedb.service: Consumed 1.459s CPU time.
Oct 9 00:00:19 camelback audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=mlocate-updatedb comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Oct 9 00:00:19 camelback audit: BPF prog-id=0 op=UNLOAD
Oct 9 00:00:50 camelback krunner[1683939]: 56131.758 Info AppManagerStates.cpp:1903: Saving finished
Oct 9 00:00:50 camelback krunner[1683939]: Restarted systemd
Oct 9 00:00:51 camelback systemd[7500]: Starting Update git repos...
Oct 9 00:00:51 camelback systemd[7500]: Starting Update vim plugins...
"""
Can you write a program that counts how many lines are from
systemd, audit, and krunner?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment