Reputation: 87
a = [(0, "Hello"), (1,"My"), (3, "Is"), (2, "Name"), (4, "Jacob")]
This is an example of a list, but when I try to this this it doesn't work:
if time < a[3]:
print ("You did it!")
The problem is that I can't apparently compare a tuple with an int, but I only want to compare it to the first number in the tuple. How can I do this?
Upvotes: 0
Views: 389
Reputation: 78554
This?
if time < a[3][0]:
# ^
print ("You did it!")
You can index the tuple the same way you did with the list.
Upvotes: 4