0
user_input=input: x = float(input(''enter number'')) While x != 1 try: x/2 except: x*3+1
another syntax error, i'm sorry, i was trying to do the collatz conjecture
9 odpowiedzi
+ 1
user_input=float(input("enter a whole number"))
result=[]
x =user_input
while x>1:
if x%2==0:
x=x/2
result.append(x)
else:
x=3*x+1
result.append(x)
print(result)
0
there should be a colon at the end of while line
0
but the error says that the error is in the user_ input line
0
oh,thanks
0
i've tried your code, guess what? syntax error!
0
it runs on my side. make sure to use correct indentations.
0
i will try tomorrow on my laptop, thanks for the help
0
i'm already thinking on printing every steps that does to reach 1 (please don't spoil anything I want to figure it out myself)
0
I would get the input before converting to float. that way you can use it to get things like "quit" or "done" if you later choose to