Len's slice- Sorting not working?

I’m trying to sort my 2D list/array, but it’s not working and I can’t figure out why.

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

print(pizza_and_prices)

pizza_and_prices.sort()

pizza_and_prices should be a list of lists
so you are missing a [ at the beginning and a ] at the end

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