Back to Freecodecamp

Try/Except

curriculum/challenges/english/blocks/error-handling-files-and-modules-in-python/try-except-video.md

latest608 B
Original Source

--description--

In this video, you will learn how to handle exceptions using try/except blocks to make your programs more robust.

--questions--

--text--

What will be the result for the following code if the user provides the string "random"?

python
try:
    number = int(input("Enter a number: "))
    print(number)
except:
    print("Invalid Input")

--answers--

Nothing will be output to the console.


The string "random" will be output to the console.


The string "Invalid Input" will be output to the console.


The program will crash.

--video-solution--

3