-3
如何将此while循环转换为函数,以便多次调用它。将while循环转换为函数
i = 0
numbers = []
while i < 6:
print "At the top of 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
这实际上是一个非常有效和有趣的问题。不是OP所要求的内容,而是动态代码创建。 – Nav 2017-12-31 16:58:56