Back to Lesson
ValueError on Cast
Catch an error when attempting to cast an invalid string to an integer.
Instructions
- In ablock, attempt to assign
try.val = int("hello") - If it succeeds, print the value.
- Catch theand print
ValueError."Invalid number format"
main.py
main.py
Ctrl + Enter