Raising Exceptions

suggest change

If your code encounters a condition it doesn’t know how to handle, such as an incorrect parameter, it should raise the appropriate exception.

def even_the_odds(odds):
    if odds % 2 != 1:
        raise ValueError("Did not get an odd number")
    
    return odds + 1

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents