以下问题是在我的一个能力倾向测试中提出的。我尝试使用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
输出和输入的格式如下:
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
因此,我将所有名称都提供给一个名为 Patient[] 的数组。我的问题程序如下:
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)
您不能迭代range(0,)
,因为没有定义终点,它必须range(0,len(patient))
那么这就是你的循环的样子:
for i in range(0,len(patient)):
item=input()
if item not in patient:
print(item)