简体   繁体   English

我收到“内部检查系统错误”

[英]i am getting “internal check system error”

I have defined a variable in the program but it is not working.我在程序中定义了一个变量,但它不起作用。 The user will input the number to view animals and enter "exit" to end the program.用户将输入数字查看动物并输入“退出”以结束程序。 The program will run in a loop.程序将循环运行。

animals = [camel, lion, deer, goose, bat, rabbit]
x = input("Please enter the number of the habitat you would like to view: ")
while True: 
    if x != ("exit"):
         print(animals[(int(x))])
    else: x == ("exit")
    print("See you later!")
exit

This will work.这将起作用。 Your list elements should be in string format " "您的列表元素应该是字符串格式“”

animals = ["camel","lion","deer", "goose", "bat", "rabbit"]
x = int(input("Please enter the number of the habitat you would like to view: "))
while True: 
    if x != ("exit"):
         print(animals[x])
         break
    elif (x == ("exit")):
        print("See you later!")
animals = ["camel", "lion", "deer", "goose", "bat", "rabbit"]

In python , every string value should be written inside double or single quotes在 python 中,每个字符串值都应该写在双引号或单引号内

In your code , your list elements were not in quotes.在您的代码中,您的列表元素不在引号中。

But yes , its possible to have a list like yours.但是,是的,有可能有一个像你这样的清单。 But then the python recognizes these as variables但是随后python将这些识别为变量

From the code you have given , it is understandable that these variables are not assigned a value before从您给出的代码中,可以理解这些变量之前没有赋值

Thus you got the variable error因此你得到了变量错误

You have to take input inside the while loop otherwise it will continue printing, and you cannot able to input next time你必须在while循环内输入,否则它会继续打印,你下次不能输入

animals = ["camel", "lion", "deer", "goose", "bat", "rabbit"]
while True:
    x = input("Please enter the number of the habitat you would like to view: ")
    if x != ("exit"):
         print(animals[(int(x))])
    else:
        x == ("exit")
        print("See you later!")
        break

暂无
暂无

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

相关问题 为什么我收到内部服务器错误 - Why am I getting an Internal Server error 为什么我会收到 500 内部服务器错误消息? - Why am I getting the 500 Internal Server Error message? BeautifulSoup:为什么会出现内部服务器错误? - BeautifulSoup: Why am i getting an internal server error? 为什么在使用MySQLdb连接时,烧瓶中出现500个内部服务器错误? - Why am I Getting 500 internal server error in flask while connecting using MySQLdb? "为什么在使用 Heroku 部署 Django 时出现内部服务器错误(管理页面仍然有效)?" - Why am I getting an internal server error when deploying Django with Heroku (admin page still works)? 为什么在导入本地 python 文件时出现 500 内部服务器错误? - Why am I getting a 500 Internal Server Error when importing local python file? 为什么通过python请求调用rest api时出现500 Internal Server Error? - Why am I getting 500 Internal Server Error when calling post rest api via python request? 对Yelp API进行身份验证时,我在本地Python服务器上收到内部服务器错误 - I am getting an internal server error on my local Python server when authenticating to Yelp API 内部检查系统错误 - 传递命令行参数 - Internal check system error - passing command line arguments 在生产服务器上部署期间,我在 django 应用程序中收到 500 内部服务器错误 ModuleNotFoundError: No module named 'main' (wsgi:error) - I am getting 500 Internal Server Error in django app during deloying on production server ModuleNotFoundError: No module named 'main' (wsgi:error)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM