+ 1

Python. Can someone please explain me what's the problem?

a = int(input()) while a!=1 print (a) if a & 2 == 0: a = a // 2 else: a = 3 * a + 1 print (a) I am trying to create to collatz project and it shows me an error. Can someone please say what's the problem.

29th Apr 2019, 7:34 PM
JohnSia2005
9 odpowiedzi
+ 3
Thanks Anya, Dima Makieiev and Dmitriy Novak
29th Apr 2019, 7:47 PM
JohnSia2005
+ 2
You forgot in while the : the the end
29th Apr 2019, 7:45 PM
Anya
Anya - avatar
+ 1
You need to ad colon in while while a!=1:
29th Apr 2019, 7:46 PM
Dima Makieiev
Dima Makieiev - avatar
0
Anya After 1?
29th Apr 2019, 7:46 PM
JohnSia2005
0
JohnSia2005 Like Dima Makieiev suggested
29th Apr 2019, 7:47 PM
Anya
Anya - avatar
0
Hi! You mist colon in while loop. It should be: while a != 1:
29th Apr 2019, 7:49 PM
Dmytro Novak
Dmytro Novak - avatar
0
Dmitriy, Anya, Dima Makieiev There's a mistake at if a % 2 == 0. Whats the mistake?
29th Apr 2019, 7:53 PM
JohnSia2005
0
Dmitriy, Anya, Dima Makieiev There's a mistake at if a % 2 == 0. Whats the mistake?
29th Apr 2019, 7:53 PM
JohnSia2005