Introduction To Python - Learn Python the hard way v2.0
Title: Exercise33
# Exercise 33: while loop
i = 0
numbers = []
while i < 6:
print "At the top i is %d" % i
numbers.append(i)
i = i + 1
print "Numbers now:", numbers
#following syntax we can write by replacing % by comma(,)
print "At the bottom i is %d" % i
print "The numbers:"
for num in numbers:
print num
#it's the simple stuff which we use to do in all langauges but realy got the many more stucks when we try to run application by typing and not by copy
"""
ayyaj@asayyad-Ub-in:~/ayyaj/training/python$ python ex33.py
At the top i is 0
Numbers now: [0]
At the bottom i is 1
At the top i is 1
Numbers now: [0, 1]
At the bottom i is 2
At the top i is 2
Numbers now: [0, 1, 2]
At the bottom i is 3
At the top i is 3
Numbers now: [0, 1, 2, 3]
At the bottom i is 4
At the top i is 4
Numbers now: [0, 1, 2, 3, 4]
At the bottom i is 5
At the top i is 5
Numbers now: [0, 1, 2, 3, 4, 5]
At the bottom i is 6
The numbers:
0
1
2
3
4
5
"""
#output for this application
