+ 2

I need help regarding this code. [Python]

I've written a code for Collatz Conjecture. But I don't know why the while loop in this code doesn't stops after the variable 'num' reaches to 1. https://www.sololearn.com/learn/6768/?ref=app https://code.sololearn.com/cZK5y7tl6AS7/?ref=app

26th Mar 2019, 3:45 PM
Abdul S Ansari
Abdul S Ansari - avatar
2 odpowiedzi
+ 1
I believe the problem lies in your second if clause. 1%2 will not return 0 so you might change this to an else since you have to do this anyway if the first case is not true.
26th Mar 2019, 4:23 PM
ChrA
ChrA - avatar
0
Christian Andrä Thank you so much, it worked
26th Mar 2019, 4:26 PM
Abdul S Ansari
Abdul S Ansari - avatar