Errors and try/except · exercise 1 of 1 · free preview
The game so far · chapter 12
Right now: Pip's sensors send glitchy readings, and the program crashes on them.
This chapter's mission: Lets Pip read glitchy sensors. Work through the exercises, then your own code brings it to life.
When something can fail, wrap it in try: and say what to do on failure with except: try: ... except ValueError: ...
int("abc") crashes. Try to print int(text), and if it raises a ValueError, print Bad number instead.