Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
竞争编程:如何检查python列表中是否存在变量的值?_Python_List_Conditional Statements - Fatal编程技术网

竞争编程:如何检查python列表中是否存在变量的值?

竞争编程:如何检查python列表中是否存在变量的值?,python,list,conditional-statements,Python,List,Conditional Statements,以下问题是在我的一次能力倾向测试中提出的。我尝试使用python解决。问题如下: COVID19 Patients are with identity numbers from 1 to 10. But few patients are escaped from quarantine. Find out those patients and write their names and details. Below are details of patients. 1 Raju

以下问题是在我的一次能力倾向测试中提出的。我尝试使用python解决。问题如下:

   COVID19 Patients are with identity numbers from 1 to 10. 
But few patients are escaped from quarantine. 
Find out those patients and write their names and details.
 Below are details of patients.

 1 Raju 
2 Ravi 
3 Lakshmi 
4 Yash 
5 Renu 
6 Tanvi 
7 Usha 
8 Vicky 
9 Rocky

10 Manu
patient=[
"Raju",
"Ravi",
"Lakshmi",
"Yash",
"Renu",
"Tanvi",
"Usha",
"Vicky",
"Rocky",
"Manu"
]

for i in range(0,):
item=input()
if item not in patient:
    print(item)
输出和输入的格式如下:

Input Format

Line 1: String
Line 2: String 
Line 3: String 
Line 4: String 
Line 5: String 
Line 6: String 
Line 7: String 
Line 8: String
Line 9: String


Constraints

None

Output Format

Line 1: String
示例输入和输出如下所示:

Sample Input 0

Raju
Ravi 
Lakshmi
Yash
Tanvi
Usha
Vicky
Rocky 
Manu

Sample Output 0

Renu
因此,我已将所有名称赋予svaed一个名为Patient[]的数组。我的问题程序如下:

   COVID19 Patients are with identity numbers from 1 to 10. 
But few patients are escaped from quarantine. 
Find out those patients and write their names and details.
 Below are details of patients.

 1 Raju 
2 Ravi 
3 Lakshmi 
4 Yash 
5 Renu 
6 Tanvi 
7 Usha 
8 Vicky 
9 Rocky

10 Manu
patient=[
"Raju",
"Ravi",
"Lakshmi",
"Yash",
"Renu",
"Tanvi",
"Usha",
"Vicky",
"Rocky",
"Manu"
]

for i in range(0,):
item=input()
if item not in patient:
    print(item)

您不能在
范围(0,)
上迭代,因为没有定义终点,它必须是
范围(0,len(patient))

这就是循环的外观:

for i in range(0,len(patient)):
    item=input()
    if item not in patient:
        print(item)

为什么要在
范围(0,)
上迭代?那是一个空范围。