我已经通过 for 循环访问嵌套列表,但我无法获得结果?
I have given nested list accessing via for loop, but I can't getting result?
patientsList=[['sagar','9856782311'],['mahsh','7865423158']]
patient=['mahsh','7865423158']
search=input("Enter mobile number of patient to search")
for i in patientsList:
for j in patient:
if search==patientsList[i][j]:
print("required patient is")
print(patient)
print( "is Appointed")
break
else:
print("Not appointed")
我需要检查列表中是否存在搜索元素,
但我无法将 'search' 与列表元素进行比较,
搜索是用户输入的手机号码进行搜索
patientsList = [['sagar','9856782311'],['mahsh','7865423158']]
search = input("Enter mobile number of patient to search: ")
for patient in patientsList:
'''
patient looks like this ['sagar','9856782311']
patient[0] is the name
patient[1] is the phone number
'''
if search == patient[1]:
print("Required patient is")
print(patient)
print("is Appointed")
break
patientsList=[['sagar','9856782311'],['mahsh','7865423158']]
patient=['mahsh','7865423158']
search=input("Enter mobile number of patient to search")
for i in patientsList:
for j in patient:
if search==patientsList[i][j]:
print("required patient is")
print(patient)
print( "is Appointed")
break
else:
print("Not appointed")
我需要检查列表中是否存在搜索元素,
但我无法将 'search' 与列表元素进行比较,
搜索是用户输入的手机号码进行搜索
patientsList = [['sagar','9856782311'],['mahsh','7865423158']]
search = input("Enter mobile number of patient to search: ")
for patient in patientsList:
'''
patient looks like this ['sagar','9856782311']
patient[0] is the name
patient[1] is the phone number
'''
if search == patient[1]:
print("Required patient is")
print(patient)
print("is Appointed")
break