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 - ValueError:以10为底的int()的无效文字:'skip',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33878400/

10-12 21:09