14. It's Dangerous to Go Alone Help!


#1


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

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

Not sure what the issue is. Very confused over all. Could anyone supply me with the answer/ correct 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']
inventory.sort(backpack)
inventory['backpack'].remove('dagger')
del inventory['gold']
inventory['gold'] = inventory['gold'] + 50


#2

@20dannyb,

Have a close look at

inventory.sort(backpack)

I think you want to sort the list of inventory['backpack']

#3

Thank you very much!
inventory['backpack'].sort() worked out.