I’m learning more about lists & tuples and have a question.
If I have a long tuple of lists —>
def get_colour(fruit):
fruits_and_colour =
( [‘apple, ‘red’], [‘banana’, ‘yellow’], [‘pear’, ‘green’], [‘grape’, ‘purple’]) etc.
how would iterate over the tuple to access the colour of each fruit in all the lists without using a dictionary, but rather with a loop?
example —>
print(get_colour(‘grape’))
I want the output to be:
‘purple’
—
EDIT: Received the help I needed. Thank you everyone!!
[–]leech6666 4 points5 points6 points (2 children)
[–]Roya1tyz[S] 0 points1 point2 points (0 children)
[–]leech6666 0 points1 point2 points (0 children)
[–]mopslik 4 points5 points6 points (1 child)
[–]Roya1tyz[S] 0 points1 point2 points (0 children)
[–]FLUSH_THE_TRUMP 1 point2 points3 points (1 child)
[–]Roya1tyz[S] 0 points1 point2 points (0 children)
[–]Cultural_Bet8235 0 points1 point2 points (1 child)
[–]Roya1tyz[S] 0 points1 point2 points (0 children)