i = 0
numbers = []
while i < 6:
print "At the top i is %d" % i
numbers.append(i)
i = i + 1
print "Numbers now: ", numbers
print "At the bottom i is %d" % i
print "The numbers: "
for num in numbers:
print num
加分习题
1. 将这个 while 循环改成一个函数,将测试条件(i < 6)中的 6 换成一个变量。