Challenge
Counter
Refactor the level counter from "Entries per level": replace the dict and counts.get() with collections.Counter, which starts every key at 0, then list the levels from most to least common with…
Showing 1–10 of 76
Challenge
Refactor the level counter from "Entries per level": replace the dict and counts.get() with collections.Counter, which starts every key at 0, then list the levels from most to least common with…
Challenge
record_launch() adds 1 to a global counter and stops with an UnboundLocalError. Predict it, find out why Python treats the name as local, fix it by passing the count in and returning the new one, then…
Challenge
…mission log into answers: parse each line into a dict, count the entries per level and per hour, find the first ERROR, then rank the subsystems by how many warnings they raised.
Challenge
Count the entries and the WARN lines in a multi-line mission log with count(), fix the count when a message mentions WARN itself, then summarise the log by level.
Example
Tuples have only two methods: count() for counting and index() for searching.
Challenge
…next reading, so it never ends. Predict it, find the stuck counter, fix it, then write a wait that gives up when the readings run out.
Challenge
Count the mission log's entries per level, INFO, WARN and ERROR, in a dict of counters, then count any level at all with get() when DEBUG lines turn up, and print the levels in alphabetical order.
Challenge
Print a launch countdown from T-10 to T-0 with range(10, -1, -1), adding a hold line at every second listed in holds, then scrub the launch at a given second with break, or print Liftoff! at the end.
Example
Searching, replacing and splitting text. Advanced string manipulation methods.
Challenge
…a for loop runs it over every temperature in a list, then count the WARN and CRITICAL readings for a summary line.