[英]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.