def collatz(n):
if n % 2 == 0:
n=n//2
else:
n=n*3 + 1
print('Please type a number')
m=int(input())
while m != 1:
m=collatz(m)
print(m)
总是提示我
Traceback (most recent call last):
File "D:/Python/Collatz sequence.py", line 10, in <module>
m=collatz(m)
File "D:/Python/Collatz sequence.py", line 3, in collatz
if n % 2 == 0:
TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'