Challenge
Clear error messages
…with a message that shows the bad value, then raise TypeError, checked first, when the length isn't a number at all.
Showing 1–10 of 14
Challenge
…with a message that shows the bad value, then raise TypeError, checked first, when the length isn't a number at all.
Quiz
…quiz: 15 Python errors to read and fix – NameError, TypeError, ValueError, IndexError, KeyError, IndentationError and ZeroDivisionError.
Challenge
code[0] = "X" stops with a TypeError, because Python strings can't be changed. Predict the crash, find out what methods and slices really give, build a new string instead, then swap a letter in the…
Challenge
A crew count read with input() crashes when 1 is added to it. Predict the crash, find out what input() really returns, fix it with int(), then write a packing tool that reads two numbers.
Challenge
A status line crashes with a TypeError because it joins text and a number with +. Predict it, read the error, fix it with str(), then build a docking status line.
Challenge
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…
Challenge
A Python program stops 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.
Challenge
…of a number, and the check from "Alert level" stops with a TypeError in the middle of a pass. Extend your check so a missing reading is reported, not crashed on, then handle missing values in the…
Article Python Fundamentals
…and Python stops you straight away: greet_astronaut() TypeError: greet_astronaut() missing 1 required positional argument: 'name' As error messages go, this is a kind one. It tells you which function…
Challenge
…but response_text is text, and the program stops with TypeError: string indices must be integers . Turn the text into a dict with json.loads() , then add a line for crewed : Launch: Lumen-3 Provider…