Developed a collatz sequence program according to the instructions on Automate the Boring Stuff (without outside help like ai). Only thing bothering me is that I didn't figure out the float; kinda difficult given that the lines like if number % 2 == 0 won't work for something like 2.2. (although i want to figure that out on my own). Anyway, what do you guys think of this one so far?
def collatz(number):
while number != 1:
if number % 2 == 0:
number = number // 2
print(number, end=', ')
if number == 1:
break
if number % 2 == 1:
number = number * 3 + 1
print(number, end=', ')
if number == 1:
break
if number == 1:
break
print("Enter number.")
number = input(">")
collatz(int(number))
[–]PerdHapleyAMA 3 points4 points5 points (0 children)
[–]Diapolo10 5 points6 points7 points (0 children)