LearnFrenzy
Sign in Take a free test

Exception Handling · Find the Error · Question 10

Error: re-raising when nothing is being handled Answer, explanation & discussion

  • Find the error
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 10 Back to Exercise

The program below stops with an error. Which statement correctly describes the problem?

main.py
def check(stock):
    if stock < 0:
        raise
    return stock

check(-1)
  • A It returns -1
  • B ValueError
  • C SyntaxError
  • D RuntimeError: a bare raise re-raises the active exception, and there is none; raise a specific exception such as ValueError("negative stock") Correct
Correct Answer: Option D

Python reports "No active exception to reraise".

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links