New course! Every coder should learn Generative AI!
Try a free lesson0
[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
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
+ 2
Just swap the position of print and increment statement
+ 1
At 10 it pass the condition then it increments to 11 and then you printed it so that's why 11 is there
+ 1
because you increment i before you print it in the while loop. print it first and it will stop at 10
0
When i is 10.
10 <= 10 is true.
Thus 11 is printed.