Press ▶ Run to see what your program does.
Lesson 30: Error detective
Level 4, Python First Steps. Read Python’s red text and fix four bugs. The new word: traceback. It follows lesson 29, Your first .py file. Next comes lesson 31, Project: Mad Libs.
What the lesson explains
Error detective. The red text Python prints is called a traceback.
The line and the name. It says which line, and what kind of problem. On the card: prnt("Hi")
What you do first
Four bugs. Fix the NameError. The editor opens with: print("Ready?") / prnt("Hi"). One way to write it: print("Ready?") / print("Hi"). It prints: Ready? / Hi.
The code on the screen
The line and the name. The editor shows 2 lines: print("Ready?") / prnt("Hi"). Run it, and Python stops with red text: NameError: name 'prnt' is not defined.
What you practise
Fix it, "Four bugs": Fix the NameError. The editor opens with: print("Ready?") / prnt("Hi"). One way to write it: print("Ready?") / print("Hi"). It prints: Ready? / Hi. Then: Fix the SyntaxError. The editor opens with: print("Go!". One way to write it: print("Go!"). It prints: Go!. Then: Fix the TypeError. The editor opens with: stars = 3 / print("Stars: " + stars). One way to write it: stars = 3 / print("Stars: " + str(stars)). It prints: Stars: 3. Then: Fix the ValueError. The editor opens with: n = int("five") / print(n). One way to write it: n = int("5") / print(n). It prints: 5.
Name the error, "Which red text?": print(scor) when the box is called score The answer: "NameError". Then: print("hi" with no closing bracket The answer: "SyntaxError". Then: print(10 / 0) The answer: "ZeroDivisionError".
What PlayBuddy and PlayType say
PlayType: "Error detective time! Red text always tells you where to look."
PlayBuddy: "Find the line number first. That is where the clue is hiding."
Help in every lesson
Everything happens on a pretend computer in your browser, so nothing touches your real files. PlayBuddy and PlayType stand beside the board, cheer you on and say when it is your turn.
A green ring shows where to click the first time. After that you do it on your own, and if you slip twice the ring comes back.
Stars
The lesson has 7 things to do. Up to one slip in ten gives three stars, up to one in four gives two, and finishing always gives at least one. Stars and progress are saved in this browser only; there is no account.
About DayOneCode
DayOneCode is an independent learning site, not affiliated with or endorsed by Anthropic. Claude and Claude Code are trademarks of Anthropic.