Results for “index”

Showing 11–20 of 41

  1. 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.

    Write the code Medium 2 stages for loop lists append filtering
  2. Challenge

    JSON out

    …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.

    Write the code Easy 2 stages json json.dumps modules import
  3. Challenge

    Date and time from a timestamp

    …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…

    Write the code Easy 2 stages strings slicing indexing timestamp
  4. Challenge

    Assignment in a condition

    …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.

    Fix the code Easy 3 stages if else == SyntaxError
  5. Article Mini projects

    Medical dispenser - Don’t trust the user

    …'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…

  6. Challenge

    Strings don't change

    …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…

    Fix the code Easy 3 stages strings immutability slicing TypeError
  7. Challenge

    Search the log

    …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…

    Write the code Medium 2 stages strings in find slicing