Results for “errors”

Showing 1–10 of 32

  1. Challenge

    Clear error messages

    …fuel_needed() about a burn of -5 seconds, after a sign error somewhere upstream, and got back -62.5 kg. Nobody noticed until the fuel budget came out 62.5 kg short. A function that gets a value it…

    Write the code Medium 2 stages errors raise ValueError TypeError
  2. Challenge

    Test the error

    …so a version that returns a value or raises the wrong error fails it, then pin down the message and the lengths that must still work.

    Write the code Medium 2 stages testing assert try except
  3. Challenge

    Catch what you expect

    …from a typo. Predict the last line, find the hidden error, catch only ValueError and fix the typo, then write a parser that lets other errors through.

    Fix the code Medium 3 stages errors try except ValueError
  4. Challenge

    First error

    Scan the mission log for the first ERROR entry, print its line number with enumerate() and stop there with break, then report how many lines were checked, or that there were no errors at all.

    Write the code Easy 2 stages for loop break enumerate flags
  5. Challenge

    Read the traceback

    …with a traceback. Read it from the bottom up to find the error, the function and the line, fix the bug there, then follow a longer traceback through four calls to a second bug.

    Fix the code Easy 2 stages errors traceback KeyError TypeError
  6. Challenge

    Flight software review

    A 40-line pre-burn check has 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…

    Fix the code Hard 2 stages project debugging SyntaxError TypeError
  7. Challenge

    Assignment in a condition

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

    Safe number input

    The burn length is typed in by hand, and a typo stops the program with a ValueError. Catch it with try and except, keep asking until the input is a number, then also turn away zero and negative…

    Write the code Easy 2 stages errors try except ValueError