Need help with a python project

I am trying to sort a list in ascending order by price. Here is the list:

pizza_and_prices=[2, “pepperoni”], [6, “pineapple”], [1, “cheese”], [3, “sausage”], [2,“olives”], [7, “anchovies”], [2, “mushrooms”]

I thought to sort by ascending order, I could just use pizza_and_prices.sort()
This gives me the error message:

Traceback (most recent call last):
File “script.py”, line 9, in
pizza_and_prices.sorted()
AttributeError: ‘tuple’ object has no attribute ‘sorted’

How do I fix this?

1 Like

put another [ and ] around pizza_and_prices
so that pizza_and_prices is a list of lists:

pizza_and_prices = [ [2, "pepperoni"], [6, "pineapple"], [1, "cheese"], [3, "sausage"], [2,"olives"], [7, "anchovies"], [2, "mushrooms"] ]