May i solve 14/14 like this?


#1
inventory = {
'gold' : 500,
'pouch' : ['flint', 'twine', 'gemstone'], # Assigned a new list to 'pouch' key
'backpack' : ['xylophone','dagger', 'bedroll','bread loaf'],
'pocket' : ['seashell','strange berry','lint'],
inventory['backpack'].sort()
inventory['backpack'].remove('dagger'),
gold.append(50)

}


#2

I'm having some trouble as well. My code looks like this.

   inventory = {
    'gold' : 500, 
    'pouch' : ['flint', 'twine', 'gemstone'], 
    'pocket' : ['seashell', 'strange berry', 'lint'],
    'backpack' : ['xylophone','dagger', 'bedroll','bread loaf']
}

inventory['burlap bag'] = ['apple', 'small ruby', 'three-toed sloth']

inventory['pouch'].sort() 

inventory['backpack'].sort()
inventory['backpack'].remove('dagger')
inventory['gold'].append(50)

It keeps telling me that my code threw the following error: 'int' object has no attribute 'append'.


#3

N/M

Just figured it out. :smiley:

    inventory = {
    'gold' : 500, 
    'pouch' : ['flint', 'twine', 'gemstone'], 
    'pocket' : ['seashell', 'strange berry', 'lint'],
    '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['backpack'].sort()
inventory['backpack'].remove('dagger')
inventory['gold'] += 50

#4

My python code looked exactly like yours the first time, same exact. Then I read the solution, your solution, and realized it was kind of already there and more obvious than I realized. So thanks!


#5

Quick question Chuck.

Why do we use += 50 and not =+50?

The latter seems more logical, doesn't it?


#6

How i did?
Look pic


#7

tanks bruv it really helped bruv


#8

thanks netninja...the last one (the gold) is very confusing at the moment..it only take += 50 and everything done..thanks..


#9

yh thanks for the help