Home
Tracks
Reset
Help
Theebug — Learn Python by Doing
Light
Explorer
···
▼
THEEBUG
lesson1.py
lesson2.py
lesson3.py
lesson4.py
lesson5.py
lesson6.py
lesson7.py
lesson8.py
lesson9.py
Completed
0/9
Score
0
PY
lesson9.py
×
THEEBUG
›
lesson9.py
1
def
parse_number
(
text
)
:
2
try
:
3
return
int
(
text
)
4
______
______
:
5
return
None
6
7
print
(
parse_number
(
"42"
)
)
#
42
8
print
(
parse_number
(
"invalid"
)
)
#
None
TERMINAL
PROBLEMS
OUTPUT
DEBUG CONSOLE
⊕
⋮
$
[system] Theebug ready. Happy coding!
Code Blocks
Drag blocks into the drop zones above
8 blocks available
except
catch
error
finally
ValueError
TypeError
KeyError
Exception
Game Panel
0:00
0 pts
Level 9 of 9
Error Handling
0/2 slots correct
Objective
Complete the try/except keyword AND name the specific exception type so a parsing failure returns None instead of crashing
Expected Output
42
None
Debug says:
Two blanks this time! First: which keyword catches an error if it raises? Second: int("invalid") raises a specific kind of error — which one?
Debug the Worm