+ 2
when does a while loop end normally?
Leaving a blank line will end a loop?
3 Answers
+ 3
Nope a while loop is going so long until the code after while isnt true anymore for example:
i = 1
while i <=5:
print(i)
i = i + 1
so i starts with being 1 and the while loop is saying:
"Im printing while i is smaller then 5" So that means when i is bigger than 5 it stops looping. and the loop said print i and i= i + 1 so the output is :
1
2
3
4
5
and then the while loop stops cause the while loop said it only loops when 5 is bigger then i .
My English isn't very good but i hope i helped you out a bit.
+ 1
In C , C++ You may know that while {..} in between the curly braces we can provide the statements. but while here how I can declare statements for while loop ..
0
while expression:
statement(s)