簡體   English   中英

嗨,我的程序中有一個錯誤,我不知道,但是當我輸入任何內容時它一直告訴我輸入無效

[英]Hi, I have a bug in my program, I don't know but it keeps telling me invalid input when I entered anything

好的,我正在嘗試構建一個猜數字游戲,我沒有開發,只有多語言系統,我需要幫助,你可以在 python 中測試它,看看它是否有效? 如果沒有,請編輯或評論我的問題,謝謝!

"""
Guess The Number
Write a program where the computer randomly generates a number between 0 and 20.
The user needs to guess what the number is.
If the user guesses wrong, tell them their guess is either too high, or too low.
This will get you started with the random library if you haven't already used it.
"""

def ENGLISH_hello():
    print("Hi, welcome to guess the number, here, you will guess a number from 1 to 100")
def CHINESE_hello():
    print("你好,歡迎你到猜數字, 在這里,你護額才一個數字從1到100")
def chinese_guess():
    print('ALL IS WELL')
def english_guess():
    print('ALL IS WELL')
def guess_the_number():
    try:
        Language = input("Hi, if you are fluent in english, type 'E'. 你好,如果你會說中文,請打 'Z'")
        if Language.strip == "z" or Language.strip == "Z":
            chinese_guess()
        elif Language.strip == "e" or Language.strip == "E":
            english_guess()
        else:
            print("INVALID INPUT")
            guess_the_number()

    except Exception as E:
        print("Sorry, something went wrong: " + str(E))

guess_the_number()

String.strip是 function 所以它應該用作 Language.strip()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM