I\'m trying to write a Collatz program using the guidelines from a project found at the end of chapter 3 of Automate the Boring Stuff with Python. I\'m using python 3.
def collatz(number):
if(number%2==0):
n=number//2
print(n)
return n
else:
ev=3*number+1
print(ev)
return ev
num1=input("Enter a number: \n")
try:
num= int(num1)
if(num==1):
print("Enter an integer greater than 1")
elif(num>1):
a=collatz(num)
while(True):
if(a==1):
break
else:
a=collatz(a)
else:
print("Please, Enter a positive integer to begin the Collatz sequence")
except:
print("please, Enter an integer")
Try to came up with a solution based on up to chapter Function from automate the boring stuff. If need help related to Collatz Problem, then visit here: http://mathworld.wolfram.com/CollatzProblem.html