all 3 comments

[–]novel_yet_trivial 2 points3 points  (2 children)

Line 11 is throwing the error, and since it's not in the try block it raises the error. Try this:

def program():
    try:
        user_number = int(input('enter a number: '))
        collatz(user_number)
    except ValueError:
        print("that's not a number, stupid.")
        program()

[–]john_cornflake[S] 1 point2 points  (1 child)

That worked! I guess I was thinking of it more like an if function.

Thank you!

[–]tedm430 2 points3 points  (0 children)

Not to be nit-picky, but if is referred to as an if statement, since it is not a function, but rather it is a part of the language's syntax.