几天前我刚刚开始学习 Python,并且正在完成 Learn Python the Hard Way 练习。我一直在搞乱while循环,我不明白为什么这个循环继续循环和循环。它基本上只是一个填充列表然后打印内容的函数。
from sys import argv
script = argv
print "This script is called %s." % script
print "It allows a list to be populated with a number"
print "Please enter that number:"
whilevar = raw_input()
i = 0
numbers = []
def list_numbers(i, whilevar):
while i < to whilevar:
print "At the top i is %d" % i
numbers.append(i)
i = i + 1
print "number present in list now ", numbers
list_numbers(i, whilevar)
print "The numbers:"
for z in numbers:
print z
这可能是非常基本的东西,但我只是以某种方式错过了它。
谢谢