Yes, as @mtf said above, this is incorrect. You cannot use sorted()
in this way.
the documentation is useful here.
https://docs.python.org/3/howto/sorting.html
we should help each other to learn not to suggest new thing instead of the person is asking. Because , everything is included step by step in the learning syllabus. So if a person doesn’t know how to use 2d list properly, how he or she will get to zip function which works like tuples.
Help?
I’m stuck on checkpoint #5. I don’t know how to print the string We sell [num_pizzas] different kinds of pizza!
, where [num_pizzas]
represents the value of our variable num_pizzas
. [num_pizza] being a the list of ingredients
My failed code is: print((“We sell”) + str(num_pizzas) “different kinds of pizza!”))
Thx in advance for any help.
Try the following:
print("We sell" + str(num_pizzas) + "different kinds of pizza!"
Or consider using fstrings:
print(f'We sell {num_pizzas} different kinds of pizza!')
Hi Seraph (Like the name!),
Sorry I haven’t replied sooner… been busy (ugh). Thanks for the coding help. I’ll be sure to use it tomorrow. I’ll let you know how I do.
Hi Seraph,
Ok really quick… I took a look a couple of days ago at your code but then forgot it. This time around I tackled the problem again without looking at your suggestion. I looked at the associated hint next to the script.py work area (fair game) … and I Got it!!!
The problem was this… I was learning at the end of my workday so I was somewhat tired. The lesson for me here is do Codecademy after I got the proper amount of rest! Thanks for your help… I’m sure I’ll need it again… LOL!
Hello folks !
I’ve stuck in #12 really simple it is ,but you know the meaning of “stuck”
that’s what i wrote : " pizza_and_prices.insert(2.5, “peppers”) "
that’s what i get this : “TypeError: integer argument expected, got float”
The insert method needs the index location as an integer for the first argument and the second argument will be the item you want to insert.
Your code below:
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)
print(“We sell " + str(num_pizzas) + " different kinds of pizza!”)
pizza_and_prices = [[2, “pepperoni”], [6, “pineapple”], [1, “cheese”], [3, “sausage”], [2, “olives”], [7, “anchovies”], [2, “mushrooms”]]
pizza_and_prices.sort()
cheapest_pizza = pizza_and_prices[0]
priciest_pizza = pizza_and_prices[-1]
pizza_and_prices.pop(-1)
pizza_and_prices.insert(4, [2.5, “peppers”])
three_cheapest = pizza_and_prices[-3:]
print(pizza_and_prices)
print(three_cheapest)