← Quiz: Exceptions in Depth: all 10 questions
Quiz: Exceptions in Depth · Question 9 of 10
Why should assert not be used to validate user input?
Why should assert not be used to validate user input?
- A.assert only works on numbers
- B.assert always raises an error
- C.Assertions are skipped when Python runs with the -O option
- D.assert cannot have a message
Answer & explanation
Correct answer: Assertions are skipped when Python runs with the -O option
Input checks must always run, so use if and raise instead.
Can you get the rest right without peeking?
Take the timed Quiz: Exceptions in Depth quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →