It's Dangerous to Go Alone! .remove trouble


#1



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


Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: 'NoneType' object has no attribute 'remove'

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

For it to get rid of the "dagger" from the list.


Replace this line with your code. 
inventory = {
    'gold' : 500,
    'pouch' : ['flint', 'twine', 'gemstone'], # Assigned a new list to 'pouch' key
    'backpack' : ['xylophone','dagger', 'bedroll','bread loaf'].sort()
}

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


#2

Get rid of the .sort() after your backpack key:value in your inventory.
Put inventory['backpack'].sort() before inventory['backpack'].remove('dagger').


#3

this not helpful, it keeps saying "Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: 'dict' object is not callable"


#4

Can you post an updated version of your code?


#5

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