所以我想作一個簡單的循環程序,但我有一個問題:的Python:簡單的循環程序
def Lottery():
Cash = 200
YourNumber = randint(1, 10)
while YourNumber != WinningNumber:
Cash = Cash - 10
if Cash < 0:
print("You are out of money!")
break
YourNumber = randint(1, 10)
else:
Cash = Cash + 100
Lottery()
的問題是,在的Def「現金」的最後一行將自動重置爲200再次重啓循環時。也許有一個非常簡單的解決方案,但我已經搜索並嘗試沒有任何結果。
請修改您的代碼以修復縮進。目前還不清楚代碼應該在哪裏。 – BrenBarn 2012-07-25 22:27:19