I want to check if there is an element in a list of array for example, I have:
horselist = [(1,"horse A","owner of A"), (2,"horse B", "owner of B")]
So if I want to check if "horse A" is in the list. I tried:
horsename_check = input("Enter horse name: ")
for i in horselist:
if (i[1] == horsename_check):
treatment = input("Enter treatment: ")
print("{0} found with treatment {1}".format(horsename_check,treatment))
else:
print("{0} id {1} profile is not in the database. "
"(You must enter the horse's profile before adding med records)".format(horsename_check, i[0]))
But if I input the horse name is : "horse B". Input will also check every array in the list and print out the statement not found in array 1.
input:
Enter the horse name:horse B
horse B id 2 profile is not in the database. (You must enter the horse's profile before adding med records)
Enter treatment:
So how can I get rid of that ? Thank you.