Results for “ValueError”

Showing 1–10 of 16

  1. Challenge

    Test the error

    Write a check that passes only when fuel_needed(-5) raises ValueError, 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…

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

    Command parser

    …such as burn 12.5 or set mode safe into tuples and raises ValueError with a reason for anything malformed, then run a whole batch of commands and report each one.

    Write the code Medium 2 stages project parsing strings split
  3. Challenge

    Clear error messages

    …negative fuel for a negative burn length. Make it raise ValueError with a message that shows the bad value, then raise TypeError, checked first, when the length isn't a number at all.

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

    Catch what you expect

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

    Safe number input

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

    Write the code Easy 2 stages errors try except ValueError
  6. Challenge

    Test the pipeline

    …value as a number, and a row from an unknown sensor raises ValueError . Then print: All checks passed Leave the functions as they are. The hidden tests plant two bugs in parse_row() : one keeps the…

    Write the code Hard 2 stages project testing assert try
  7. Challenge

    Survive bad lines

    …it skipped. Skip and count The program stops at ERR with a ValueError . Put the conversion in try ; when it fails, add 1 to a new counter, skipped , and go on to the next line. At the end, report all…

    Write the code Medium 2 stages errors try except ValueError
  8. Challenge

    Decimal comma

    An operator types 42,5 and float() crashes with a ValueError. Predict it, find out why, accept both commas and dots with replace(), then read pressures written like 1 013,25.

    Fix the code Easy 3 stages strings replace float ValueError