Results for “lists”

Showing 1–10 of 57

  1. Challenge

    Shared default list

    …remembers samples from earlier calls, because the default list is created once and shared. Predict it, prove the calls share one list, fix it with None as the default, then write a function that hands…

    Fix the code Medium 3 stages functions default values mutable defaults None
  2. Challenge

    Changed the caller's list

    add_reading() appends to the list it receives, so the caller's stored readings change too. Predict the first line, prove both names share one list, fix it by returning a new list, then write a filter…

    Fix the code Medium 3 stages functions lists mutation return
  3. Challenge

    Names with values

    Print each sensor name with its reading by looping over two lists together with zip(), then add a third list of units and warn when the lists don't have the same length, since zip() quietly stops at…

    Write the code Easy 2 stages for loop zip lists unpacking
  4. Challenge

    Prove the fix

    …add_sample() that would have caught the shared default list, then add checks that a log passed in is still the one that gets the sample, so a "fix" that breaks that can't pass either.

    Write the code Medium 2 stages testing assert regression tests default values
  5. Challenge

    Nested response

    …the rocket is a dict of its own, and the mission holds a list of patch images. The public launch page shows the rocket and the mission patch. Dig the two values out of the nested response, then make…

    Write the code Easy 2 stages dictionaries nested data lists JSON
  6. Challenge

    Crew roster

    …the commander, the newest member and the crew size from a list with [0], [-1] and len(), then add the second in command and the whole roster joined into one line.

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

    Approved payloads

    Check whether a payload ID is on the approved list with in, which matches whole items rather than parts of text, then normalise IDs typed by hand and print a clear cleared or not-cleared message.

    Write the code Easy 2 stages lists in membership if
  8. Challenge

    Backup that isn't

    backup = crew gives one list two names, so removing someone from the backup removes them from the live roster too. Predict it, prove it with is, fix it with copy(), then plan a crew swap on a real…

    Fix the code Medium 3 stages lists copy references is
  9. Challenge

    Check every reading

    …level so a for loop runs it over every temperature in a list, then count the WARN and CRITICAL readings for a summary line.

    Write the code Easy 2 stages for loop lists if elif
  10. Challenge

    Sorted copy

    The mission report lists the crew alphabetically, but the sign-up order matters too: it decides who gets the first training slots. The same list has to be shown both ways. Make a sorted copy for the…

    Write the code Easy 2 stages lists sorted sort key