Help with Len's Slice Project (Python 3, Lists)

Hi! I am on this project and I am stuck on step 11. This is the code that I have got from the pizza_and_prices 2D list:

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

pizza_and_prices.sort()
print(pizza_and_prices)

cheapest_pizza = pizza_and_prices[0]
priciest_pizza = pizza_and_prices[-1]

pizza_and_prices[-1].pop([7, "anchovies"])
print(pizza_and_prices)

In the pizza_and_prices[-1].pop([7, "anchovies"]) there is an error: TypeError: 'list' object cannot be interpreted as an integer. I have tried other variations, but I can’t seem to remove the whole [7, "anchovies"] from the end of the 2D list.

Thanks in advance for any help!

Hello!
.pop() removes the last item from the list. So, you don’t need to qualify it with a position or a value.
i.e.
pizza_and_prices.pop()
should suffice.

Hope that helps

1 Like

Yes! Thank you so much!

1 Like