How is this supposed to print 1 to 100 using while loop? Why is this getting infite 1's? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How is this supposed to print 1 to 100 using while loop? Why is this getting infite 1's?

a=1 while a<100: print(a) a+=1

13th Jun 2019, 1:18 AM
LIGHT
LIGHT - avatar
8 Answers
+ 3
a+=1 should be indented too
13th Jun 2019, 1:21 AM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 1
This code is working perfectly in my PC. It is printing numbers from 1 to 99.
13th Jun 2019, 1:27 AM
Gears Of Tech
0
can you plz write it ? I don't get it
13th Jun 2019, 1:22 AM
LIGHT
LIGHT - avatar
0
I'm using python (latest) and pycharm btw. Someone plz fix this 😭
13th Jun 2019, 1:30 AM
LIGHT
LIGHT - avatar
0
a=1 while a<100: print(a) a+=1
13th Jun 2019, 1:31 AM
✳AsterisK✳
✳AsterisK✳ - avatar
0
um.. what did you change? :/
13th Jun 2019, 1:32 AM
LIGHT
LIGHT - avatar
0
nothing Md Mursalin i just add tab to the a+=1 as I have told you earlier
13th Jun 2019, 1:33 AM
✳AsterisK✳
✳AsterisK✳ - avatar
0
omg it worked ... thanks a lot *-*
13th Jun 2019, 1:35 AM
LIGHT
LIGHT - avatar