+ 1
What does the "while" do?
Sorry,I'm beginner.
3 ответов
+ 3
while is a form of loop. it will run until told not too. example...
run=True
while run:
print("Hello World")
That would result in Hello World being written over and over and over forever because run is always True.
count=0
while count<4:
print("Hello World")
count+=1
that would print Hello World 4 times. each time the loop ran it would print the words and then add 1 to count. "While" count is less than 4 it will continue to loop
+ 3
it will run the code inside his curly brackets until the condition is false. Obviously, you need to change that condition every time the code runs, otherwise it will run infinitely.
int i;
while (i<5) { i++ }
increments variable i until it reaches 5, which is false and so it stops at 4
0
ohh,thanks you all😇