Challenge
Filter the log
…is the second word of each entry: line.split()[1] . LEVELS.index(level) gives its rank, 0 for INFO up to 2 for ERROR, so compare the ranks.
Showing 11–20 of 41
Challenge
…is the second word of each entry: line.split()[1] . LEVELS.index(level) gives its rank, 0 for INFO up to 2 for ERROR, so compare the ranks.
Challenge
…mission summary dict into JSON text with json.dumps() and indent=2, see what True, False and None become, then keep the station's Polish letters readable and sort the keys so the files compare easily.
Challenge
…the first 10 characters. The time starts after the T , at index 11, and is 8 characters long. In text[start:end] , the character at end isn't included. The way we write it In Poland and much of…
Quiz
Free beginner quiz on Python tuples: 15 questions on indexing, packing and unpacking, count(), index(), slicing and nested tuples. Instant answers.
Challenge
…check uses = instead of == and has a line that isn't indented, so Python refuses to run it. Predict what happens, fix both errors one after the other, then write an if/else check yourself.
Article Mini projects
…'w') as f: json.dump(self.event_log, f, indent=2) def _create_event(self, event_type, success, reason=""): """Create a tamper-evident event record with proper HMAC""" # Use UTC time for persistence…
Quiz
Free beginner quiz on Python lists: 15 questions on indexing, slicing, append, insert, pop, remove, sorting and copying, with instant answers.
Challenge
…Build a new code with B in place of the shift letter, at index 4, and print both: Old code: ENG-A-07 New code: ENG-B-07 Take everything before index 4, then "B" , then everything after index 4. Don't…
Challenge
…and where? Print whether the line contains ERROR , and the index where it starts: Contains ERROR: True Starts at: 13 "ERROR" in line gives True or False . line.find("ERROR") gives the index of the…
Example
Searching, replacing and splitting text. Advanced string manipulation methods.