Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

while loop in python

# It is very important to understand the logic behind the While loop
n = 3
while n>0:
    print(n)
    n = n - 1 # This can also write as (n -= 1)
print('Blastoff')
# Remember when the n=0, it does not run 
# it comes out of the while loop but the value remains in the variable
print(n)
Source by www.py4e.com #
 
PREVIOUS NEXT
Tagged: #loop #python
ADD COMMENT
Topic
Name
9+4 =