Choosing elements from nested lists

Report a typo

Imagine that the list below shows a part of a cafe's menu where the first element in each nested list is the name of a dish, the second element is the number of people the dish is aimed at, and the third number is its cost in the local currency.

menu = [["pizza", 4, 20], ["soup", 1, 8], ["ice cream", 2, 4], ["toasts", 2, 10]]

Let's say a customer wants to select what to order using Python, and they have written the following code:

what_to_order = [dish[0] for dish in menu if dish[1] >= 2 and dish[2] < 15]
print(what_to_order)

Which output will this expression yield?

Select one option from the list
___

Create a free account to access the full topic