【Python】Learn Python the hard way, ex33 while循环

来源:互联网 发布:我欲封天灵珠升阶数据 编辑:程序博客网 时间:2024/05/22 14:43
i = 0numbers = []while i < 6:    print "At the top i is %d" % i    numbers.append(i)    i += 1    print "Numbers now: ", numbers    print "At the bottom i is %d" % iprint "The numbers: "for num in numbers:    print num    """Test Result:At the top i is 0Numbers now:  [0]At the bottom i is 1At the top i is 1Numbers now:  [0, 1]At the bottom i is 2At the top i is 2Numbers now:  [0, 1, 2]At the bottom i is 3At the top i is 3Numbers now:  [0, 1, 2, 3]At the bottom i is 4At the top i is 4Numbers now:  [0, 1, 2, 3, 4]At the bottom i is 5At the top i is 5Numbers now:  [0, 1, 2, 3, 4, 5]At the bottom i is 6The numbers: 012345"""

0 0
原创粉丝点击