Tigre
Tigre

Reputation: 306

How do I take a users input and see if it's in the list

I was wondering if there is a way to take 2 user's inputs and see if it is in the list I have created before. Then if it is, then I print out the name of the users input but then if it isn't I have to say there is none. Here's an example:

Say they are all named and I wanted to print out the name of the person. Not duplicate.

[['Jon', 12, 167],['Sam', 18, 200]]

Upvotes: 1

Views: 105

Answers (1)

Habib Mohammed
Habib Mohammed

Reputation: 41

my_data = [['Jon', 12, 167],['Sam', 18, 200]]
user_input1 = int(input())
user_input2 = int(input())
my_output = ""
for i in my_data:
    print(i[1],i[2],user_input1,user_input2)
    if (i[1] == user_input1 and i[2] == user_input2):
        my_output = i[0]
        break
    else:
        my_output = "No Data Found!"
print(my_output)

if this is what you are looking for.

Upvotes: 1

Related Questions