.sort problem

https://www.codecademy.com/courses/learn-python-3/projects/python-lens-slice
#My code
Toppings = (“pepperoni”, “pineapple”, “cheese”, “sausage”, “olives”, “anchovies”, “mushrooms”)

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

num_two_dollar_slices = prices.count(2)

num_pizzas = len(toppings)

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

–>pizza_and_prices.sort()

print (num_two_dollar_slices)

print (prices)

print (“We Sell: " + str(num_pizzas) + " different kinds of pizza!”)
I’m suppose to use .sort for the order of increasing price (ascending). I enter: "pizza_and_prices.sort()
Got error, “Traceback (most recent call last):
File “script.py”, line 7, in
pizza_and_prices.sort()
TypeError: ‘<’ not supported between instances of ‘str’ and ‘int’”
I remember that’s how you get the increasing price order but it’s not working…HELP!

print (pizza_and_prices)
#Code Stop

okay, I corrected the pizza_and_prices variable by taking off "() and add ]. Another stupid mistake of mine. Anyway, I got it done!

You have a ] in the wrong place. It should after "pepperoni" (instead of at after "mushrooms"] ).

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.