Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

while loop in python

#Multiples of three 

i = 0
while True:
    print(i)
    i = i + 3
    if(i > 30):
        break
#output will be:
0 #First it will count i=0, starts from zero and for example if you put i=1,it will start from 1.
3 #Here i=0, i=0+3, so i=3 and i becomes 3 for next value. so on
6 #i=3
9 #i=6
12 #so on
15
18
21
24
27
30

Source by codehs.com #
 
PREVIOUS NEXT
Tagged: #loop #python
ADD COMMENT
Topic
Name
2+4 =