gpt4 book ai didi

python - 值错误: invalid literal for int() with base 10: 'skip'

转载 作者:太空宇宙 更新时间:2023-11-03 17:13:23 26 4
gpt4 key购买 nike

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 跳过)。每次它运行程序时,我希望它检查是否有足够的(跳过)。我们将不胜感激。

最佳答案

这更接近你想要的:

def intro(skips=3):
print ('skip')
answer = input()
if 'skip' in answer:
skips -= 1
if skips <= 0:
print('you are out of skips')
end()
elif skips > 0:
print ('You have ' ,skips, ' left')
intro(skips)
def end():
print ('you are out of skips. Game Over')

intro()

关于python - 值错误: invalid literal for int() with base 10: 'skip' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33878400/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com