Practice mode Python

Which exception is raised when a Python function recurses too deeply?

Correct answer A. RecursionError

Explanation

Python limits recursion depth to protect the C stack, and exceeding the limit raises RecursionError, a subclass of RuntimeError. Python does not perform tail-call optimisation, so even tail-recursive functions hit the limit. StackOverflowError is a Java error, not a Python one.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.