It's dangerous to go alone. Take 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']
}

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


File "python", line 5
'pocket' = ['seashell', 'strangeberry', 'lint']
^
SyntaxError: invalid syntax

This is the error I'm getting. I have no idea what to do :confused:


#2

Hello :slight_smile:

If error message points beginning of the line it usually means that something is wrong in the previous line. Take a look at it and try to find what is wrong:

'backpack' : ['xylophone','dagger', 'bedroll','bread loaf']

Hint -> we use commas to separate items in dictionary :slight_smile:


#3

inventory['pocket']=['seashell', 'strange berry', 'lint']
inventory['backpack'].sort()
inventory['backpack'].remove('dagger')
inventory['gold']+=50

you probably didn't do this right >>> inventory['pocket']=['seashell', 'strange berry', 'lint']
your missing inventory and [ ] before and over pocket.


#4

lol i wass sufering lbecause i didnt wach those #... statment ..
i thoght they messt smothing up and made a mess myself until i just folowed what they sead on the # line..

If you need it heres the whole code..:

Summary

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()

inventory['pocket']=['seashell', 'strange berry', 'lint']
inventory['backpack'].sort()
inventory['backpack'].remove('dagger')
inventory['gold']+=50


#5

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