Results for “index”

Showing 1–10 of 24

  1. Challenge

    Index by ID

    …six items, but the real manifest has thousands. Build an index from ID to record once, then answer the questions from it. Build the index Build a dict called by_id that maps each cargo ID to its…

    Write the code Medium 2 stages dictionaries indexing lookup in
  2. Challenge

    Missing index

    readings[5] on a list of five readings stops with an IndexError. Predict it, work out the valid indexes with len(), fix it with [-1], then print the first, middle and last readings for any length.

    Fix the code Easy 3 stages lists indexing IndexError len
  3. Challenge

    Crew roster

    …Commander: Okafor Newest member: Kowalska Crew size: 4 Indexes start at 0, as in strings. crew[-1] is the last item whatever the list's length, and len(crew) counts the items. The whole roster Add the…

    Write the code Easy 2 stages lists indexing negative index len
  4. Challenge

    Flight software review

    …five bugs: a syntax error, a type error, a wrong key, an index out of range and a reversed decision. Read each error to fix the four that crash, then find the one that runs but gives the wrong answer.

    Fix the code Hard 2 stages project debugging SyntaxError TypeError
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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