while loop list python code example

Example 1: python while true loop

while True:
  print("Hi")

Example 2: python while loop

while <condition>:
  <run code here>
  
# for example,
i = 0
while True:
  i += 1
  # i will begin to count up to infinity
while i == -1:
  print("impossible!")

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 in python

# while loop runs till the condition becomes false
number = 0
while number > 10:		# prints number till 10
  print(number)
  number += 1

Example 6: python while loop

while whatitis:
  #code goes here no comment