14/14 sorting stuff


#1

how do i sort stuff?


#2

A picture may tell a thousand words, but none can be copied and pasted, and it cannot be run. Please post your code.

From the picture, we can see some stray code in there that does not belong and was not asked for.


#3

I've got the code

inventory = {
    'gold' : 500,
    'pouch' : ['flint', 'twine', 'gemstone'], # Assigned a new list to 'pouch' key
    'backpack' : ['xylophone','dagger', 'bedroll','bread loaf']
}

# Adding a key 'burlap bag' and assigning a list to it
inventory['burlap bag'] = ['apple', 'small ruby', 'three-toed sloth']

# Sorting the list found under the key 'pouch'
inventory['pouch'].sort() 

# Your code here
inventory["pocket"] ="seashell",'strange berry',"lint"
start_list = [5, 3, 1, 2, 4]
square_list = []
for num in start_list:
    square_list.append(num**2)
    square_list.sort()
    print square_list
inventory["backpack"].remove("dagger")

#4

The assignment should be a list.

inventory["pocket"] = ["seashell","strange berry","lint"]

Have no idea what this code is doing in here,

start_list = [5, 3, 1, 2, 4]
square_list = []
for num in start_list:
    square_list.append(num**2)
    square_list.sort()
    print square_list

#8

I've got error even so I've tried the code as above:

"Oops, try again. square_list should be the same length as start_list"

how to fixe it?
thanks.


#9

Let's start with the lesson page. Please post a link to the exercise where you are getting this error. Thank you.


#10

when i did this i got: Traceback (most recent call last):
File "python", line 15, in
AttributeError: 'dict' object has no attribute 'sort'


#11

i don't get what's that part too


#12

To reiterate:

Let's start with the lesson page. Please post a link to the exercise where you are getting this error. Thank you.