It's Dangerous To Go Alone! Question


#1



https://www.codecademy.com/courses/python-beginner-en-pwmb1/2/5?curriculum_id=4f89dab3d788890003000096

Traceback (most recent call last):
File "python", line 14, in
AttributeError: 'str' object has no attribute 'sort'


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']
'backpack'.sort()
inventory.remove('dagger')
inventory['gold']= 550


#2

this line:

'backpack'.sort()

you can't sort a string, you should sort a list (backpack list, which is part of your inventory dictionary)


#3

I edited my code to look like this:

And I took your advice, but it came up with this error:


#4

take a look at line 11 how the pouch list inside the inventory dictionary gets sorted. you should call sort on the list, not pass it as argument


#5

Ah, thank you. I completely overlooked that.