简体   繁体   English

嗨,我的程序中有一个错误,我不知道,但是当我输入任何内容时它一直告诉我输入无效

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

okay, I was trying to build a guess the number game and I hadn't developed, only the multi-language system, I need help, can you test it in python and see if it works?好的,我正在尝试构建一个猜数字游戏,我没有开发,只有多语言系统,我需要帮助,你可以在 python 中测试它,看看它是否有效? if not, please edit or comment my question, Thanks!如果没有,请编辑或评论我的问题,谢谢!

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

The String.strip is a function So it should be used as Language.strip() String.strip是 function 所以它应该用作 Language.strip()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么系统告诉我我的系统中没有 Python 3.10? - Why is the system telling me that I don't have Python 3.10 in my system when I do? VS Code 一直告诉我我没有 Python……但我有 - VS Code keeps telling me I don't have Python… but I do 嗨,我对 python pipreqs 有一些问题。 它一直告诉我用法而不是创建正确的文件 - Hi, I have some issue with the python pipreqs. It keeps telling me the usage instead of creating the right file 我的程序一直循环,我不知道为什么 - my program keeps looping and I don't know why 由于 Python 程序中的 input() ,我收到了 EOFError 。 我什至不知道为什么我有它。 我该如何解决? - I get an EOFError because of an input() I have in my Python program. I don't even know why I have it. How should I fix it? 你好。 我的代码有一些错误,我不知道如何调试它们。 下面提到了问题和代码。 真的很感谢你的青睐 - Hi! I have a some bugs with my code and I don't know how to debug them. The question and the code is mentioned below. Really appreciate your favor 我不知道什么时候必须使用 centerx 和 centry - I don't know when i have to use centerx and centry 我的程序总是停止,我不知道为什么 - My program always stop and I don't know why 如果我不知道一个人将如何运行它,是否需要在python脚本的顶部添加任何内容? - Do I have to add anything at the top of a python script if I don't know how a person will run it 如果输入无效输入,如何让我的python程序退出并显示错误消息? - how do i get my python program to exit and show an error message if an invalid input is entered?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM