← Quiz: Exceptions and Files: all 15 questions
Quiz: Exceptions and Files · Question 7 of 15
What does this print? (code)
What does this print?
try:
x = int("5")
except ValueError:
print("bad")
else:
print(x + 1)
- A.bad
- B.6
- C.5
- D.An error
Answer & explanation
Correct answer: 6
No error, so the else block runs.
Can you get the rest right without peeking?
Take the timed Quiz: Exceptions and Files quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →