1
def intro():
global skips
skips = 3
print ('skip')
skips = int(input())
if 'skip' in skips:
skips - 1
if skips > 0:
print('you are out of skips')
end()
if skips < 0:
print ('You have ' ,skips, ' left')
intro()
def end():
print ('you are out of skips. Game Over')
intro()
我想它也帶走(1個跳過)每當有人類型(跳過)。並且每次運行程序時,我都希望它檢查是否有足夠的空間(跳過)。幫助將不勝感激。ValueError異常:無效的基數爲10字面INT(): '跳過'
你怎麼知道有人輸入「跳」? –
'skips - 1' does not nothing ... – Tempux
發生錯誤是因爲你輸入了「skip」,它是通過input()讀取的,然後傳遞給int(),它試圖轉換爲整數, ValueError' –