ValueError:以10为基数的int()的文本无效:“skip”

2024-04-24 05:22:56 发布

您现在位置:Python中文网/ 问答频道 /正文

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跳过),它也会被拿走(1跳过)。每次它运行程序时,我都希望它检查是否有足够的内存(跳过)。我们将不胜感激。在


Tags: ofinyouinputifdefoutglobal
1条回答
网友
1楼 · 发布于 2024-04-24 05:22:56

这更接近您想要的:

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()

相关问题 更多 >