user_input=input: x = float(input(''enter number'')) While x != 1 try: x/2 except: x*3+1 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

10th Nov 2016, 6:55 PM
leonardo
leonardo - avatar
9 Answers
+ 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)
10th Nov 2016, 7:37 PM
paul mwaniki
paul mwaniki - avatar
0
there should be a colon at the end of while line
10th Nov 2016, 7:15 PM
paul mwaniki
paul mwaniki - avatar
0
but the error says that the error is in the user_ input line
10th Nov 2016, 7:20 PM
leonardo
leonardo - avatar
0
oh,thanks
10th Nov 2016, 7:39 PM
leonardo
leonardo - avatar
0
i've tried your code, guess what? syntax error!
10th Nov 2016, 7:45 PM
leonardo
leonardo - avatar
0
it runs on my side. make sure to use correct indentations.
10th Nov 2016, 7:48 PM
paul mwaniki
paul mwaniki - avatar
0
i will try tomorrow on my laptop, thanks for the help
10th Nov 2016, 7:49 PM
leonardo
leonardo - avatar
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)
10th Nov 2016, 7:50 PM
leonardo
leonardo - avatar
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
11th Nov 2016, 1:46 PM
Luke Armstrong