i = 0numbers = []while i < 6: print "At the top i is %d" % i numbers.append(i) i = i + 1 print "Number now: ", numbers print "At the bottom i is %d" % iprint "The numbers: "for num in numbers: print num如何将上边这段while代码改写成一个函数,将测试条件(i<10)中的10 换成一个变量。用for loop和range重写一遍。
添加回答
举报
0/150
提交
取消