Oct-16-2019, 04:15 PM
I think the try/except solution would work better this way:
n = input("What term of the Fibonacci Sequence would you like to know? ") try: n=int(n) except ValueError: raise TypeError("n must be a positive integer.") if n<0: raise ValueError("n must be positive.")This keeps the exception checking narrow (to avoid catching errors you didn't expect), and allows you to tailor your error to the specific problem with the input.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures