Len's Slice

Hi Everyone

I’m working through Len’s Slice for the second time because I need to reinforce the basics of python. I’m on step 8 and did the pizza_and_prices.sort() step as instructed but now it returns an error saying Traceback (most recent call last):
File “script.py”, line 10, in
AttributeError: ‘tuple’ object has no attribute ‘sort’
And now I can’t move on to the latter steps. What happened to the tutorial video/or view solution steps that was here the first time round?


Check if you have a [ at the beginning of the list and a ] at the end …
For example:

ex1 = 1, 2, 3, 4  # this is a tuple

ex2 = [1, 2, 3, 4] # this is a list

or this example:

ex3 = [1,4], [2,5], [3,6]  # this is a tuple of lists

ex4 = [ [1,4], [2,5], [3,6] ] # this is a list of lists

You probably want something similar to ex4 for the exercise,
so that the outermost thing is a list, and thus has a .sort method/function

1 Like

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