これがばかげているように思われる場合は申し訳ありませんが、LPTH の演習 33 に問題があります。
http://www.learnpythonthehardway.org/book/ex33.html
代わりに for ループと範囲を使用するように演習を書き直してください。中間のインクリメンタはもう必要ですか? 取り除かないとどうなりますか?
これは私がしました:
numbers = []
def NumbersLoop(x):
"""
This function will loop as long as x is less than the limit,
at the same time it will print the numbers list
"""
limit = int(input('Limit: '))
increment = int(input('Increment: '))
for i in (x, limit):
print('At the top x is : {}'.format(x))
numbers.append(x)
x += increment
print('Numbers now: ', numbers)
print('At the bottom x is {}'.format(x))
NumbersLoop(1)
print('The numbers: ')
for num in numbers:
print(num)
しかし、なぜ3までしかループしないのかわかりません。また、途中でインクリメンタを取り除くことは可能ですか? どうしようもない...