Apr-19-2018, 11:03 AM
Hello,
I think that in your first iteration you're still comparing a char with an integer. Try to introduce '1' and verify if the execution doesn't enter to the loop. I think that you must do the cast to integer in the input() function and not in the collatz function.
I think that in your first iteration you're still comparing a char with an integer. Try to introduce '1' and verify if the execution doesn't enter to the loop. I think that you must do the cast to integer in the input() function and not in the collatz function.
try: n = int(input("Give me a number: ")) while n != 1: print(n) n = collatz(abs(n)) except ValueError: print('Type a number please!')What do you think?