while loops code example

Example 1: how to write a while statement in python

myvariable = 10
while myvariable > 0:
  print(myvariable)
  myvariable -= 1

Example 2: while loop python

while (condition):
  doThis();

Example 3: while loop in python

#there are 2 ways to make a while loop in python

#first way -

while True:
  (#what ever you want in the loop)
    
#second way - 
    
while 1:  
    (#what ever you want in the loop)

Example 4: while loop in python

#Make a variable containing an integer like shown below:
i=1
while i<=6:
  print ("Hello")
#This loop will go on forever and the only way to stop it is to kill your program

Example 5: while loop

var i=1;
while(i<=10){
document.write(i + "<br>");
i++;}

Example 6: while loop

i = 0

while i < 6:

    i += 1

  if i == 3:
    continue
  print(i)