Hi, sorry if I am not organized, I was following the steps of codecademy’s python 3 course. But at line 9 It shows me an error and I don’t understand why. Thanks for your help.
It has to do with how
.sort() works behind the scenes. Since in this instance it’s trying to sort lists, it begins comparing the contents inside each list.
This comparison is done by seeing which elements are the biggest (or I guess the smallest)
< works on integers and strings:
>>> print('a' < 'b') True >>> print(2 < 1) False
Trying to do this on an integer and a string can’t be done:
>>> print('a' < 1) TypeError: "<" not supported between instances of 'int' and 'str'
Line seven is combining two lists, but only as co-elements of another list. To actually combine them into a single list (of value pairs) they need to be
Either that or loop through them, but neither those have been gone through in the course by then (from what I can see). Zip is introduced a couple of lessons afterwards.
I think it might be the intention that you just write out a new list by hand, as it were. Could do with being a little clearer (especially in the hint).
It still comes down to creating a single list of value pairs. We can do this with the tools available…
list1 = [...] list2 = [...] combined =  for x in range(len(list1)): combined.append([list1[x], list2[x]])
Yeah, but as I say, zip is introduced two lessons after this and loops are the next section in the syllabus.
From what I can see, there’s nothing in the course up to then that could do the job.
I’ve looked into this lesson before, and I believe it is expected that the learners type out the entire combined list manually. Previously, this lesson is where zip was introduced, but some time ago it was changed. I believe that back then learners were complaining about zip being thrust on them with no previous explanation.
Anyway…, back to helping you, pablopelaez553662244.
On line 7, you’re supposed to create a new list which combines the two other lists, i.e.
pizza_and_prices = [[2, "pepperoni], [6, “pineapple”], …etc]
I think you should be good from there.
Thanks, everyone for the answers. yeah, I believe I have to put the list manually. But I think it is a little confusing the example of the lesson. I will continue learning, Thanks again.