[SOLVED] Guys why it doesnt stop in 10 ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

[SOLVED] Guys why it doesnt stop in 10 ?

I tried do an other loop,and it go until 11,but i said him go until 10 i will put the link for you see https://code.sololearn.com/cA1tQft1AN68/?ref=app

3rd May 2021, 10:43 AM
Katdotbrush
Katdotbrush - avatar
5 Answers
+ 3
i = 1 while i <= 10: //it will check till 10 and increment by 1 value i = i + 1 print (i) Try this i = 1 while i < 10://will check till 9 and increment by value 1 i = i + 1 print (i) I hope this helps you
3rd May 2021, 10:47 AM
Aysha
Aysha - avatar
+ 2
Just swap the position of print and increment statement
3rd May 2021, 10:46 AM
YUGRAJ
+ 1
At 10 it pass the condition then it increments to 11 and then you printed it so that's why 11 is there
3rd May 2021, 10:45 AM
YUGRAJ
+ 1
because you increment i before you print it in the while loop. print it first and it will stop at 10
3rd May 2021, 10:46 AM
Slick
Slick - avatar
0
When i is 10. 10 <= 10 is true. Thus 11 is printed.
3rd May 2021, 10:51 AM
你知道規則,我也是
你知道規則,我也是 - avatar