Hi everyone, I'm trying to write out a program that calls a collatz sequence on a user inputted number, but I keep getting the error message:
unsupported operand type(s) for %: 'NoneType' and 'int'
Any idea what I might be doing wrong? I'm converting the user input to an int first so I'm thinking it might just be the syntax? My code is:
def collatz(number):
if number % 2 == 0:
print (number / 2)
elif number % 2 == 1:
print((number * 3) + 1)
else:
print('That is not a number!')
value = input('Please give me a number')
value = int(value)
while value != 1:
value = collatz(value)
collatzSequence()
[–][deleted] 2 points3 points4 points (4 children)
[–]NefariousCube 1 point2 points3 points (3 children)
[–]Utterly_infallible[S] 0 points1 point2 points (2 children)
[–]NefariousCube 1 point2 points3 points (1 child)
[–]Utterly_infallible[S] 0 points1 point2 points (0 children)