My first post to this forum. Total coding newbie here. Thanks in advance for your help. Stuck on a Python 3 tutorial project. I am stuck on question #12 of the link below
https://www.codecademy.com/courses/learn-python-3/projects/python-lens-slice
I need to insert [2.5, “peppers”] into the already sorted list, see below (variable name is pizza_and_prices)
[[1, ‘cheese’], [2, ‘mushrooms’], [2, ‘olives’], [2, ‘pepperoni’], [3, ‘sausage’], [6, ‘pineapple’], [7, ‘anchovies’]]
The first incorrect code I came up with, see below, produced a “TypeError: integer argument expected, got float” …
pizza_and_prices.insert(2.5, “peppers”)
The second incorrect code I came up with …
pizza_and_prices.insert(int(2.5), “peppers”)
produced the list below that has the price, 2.5, missing …
[[1, ‘cheese’], [2, ‘mushrooms’], ‘peppers’, [2, ‘olives’], [2, ‘pepperoni’], [3, ‘sausage’], [6, ‘pineapple’]]
Help please?