Convert our toppings and prices lists into a two-dimensional list called pizza_and_prices that has the following associated values

How do I convert two different lists into a 2 Dimensional list? The only thing I could come up with is to just create a new list that takes the values of toppings and prices. It looked like this:

toppings = [“pepperoni”, “pineapple”, “cheese”, “sausage”, “olives”, “anchovies”, “mushrooms”]

prices = [2, 6, 1, 3, 2, 7, 2]

pizza_and_prices = [prices, toppings]


This might be helpful.


I tried manually creating a new 2 dimensional list and this is the error I received.

traceback (most recent call last):
File “”, line 9, in
pizza_and_prices = [[2, “pepperoni”], [6, “pineapple”] [1, “cheese”] [3, “sausage”] [2, “olives”] [7, “anchovies”] [2, “mushrooms”]]
TypeError: list indices must be integers or slices, not tuple

Is the method .zip() covered prior to this mini-project?

No, .zip is not covered prior to these tasks. My answer is supposed to look like this [2, “pepperoni”].

If the error message is accurate, it looks as though you are missing a few separators (,) in your list of lists.


Thank you, very much! The problem was indeed the missing (,) in my list.