I am just learning Python and I need some advice regarding searching items in a list. I have a list that contains a list of lists. How can I search for an item in a list and return the value from the same list like the example below.
Example:
myList = [['Red', 'Tomato'], ['Green', 'Pear'], ['Red', 'Strawberry'], ['Yellow', 'Lemon']]
word = 'Green'
return Pear
Is is possible to find the first instance or the n-th instance in the list as well?
first_instance = 'Red'
return Tomato
last_instance = 'Red'
return Strawberry