.It's Dangerous to Go Alone! Take This


#1



Python Lists and Dictionaries
It's Dangerous to Go Alone! Take This
14


File "python", line 5
} 'pocket' ['seashell', 'strange berry', 'lint']
^
SyntaxError: invalid syntax

I have also gotten the error message; Ops, try again. Did you accidentally delete the inventory dictionary? Click Reset Code to get back to the original code.


If i replace 'pocket' with ['pocket']
i just get this error message:File "python", line 8, in
TypeError: 'tuple' object does not support item assignment

Does anyone know how i fix this code.
I have tried to replace : with =
I have also tried to add commas behind the ]
But nothing work


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

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


#2

Firstly, your code doesn't look complete at the top. I will assume you copied and pasted in a haste.

You are doing otherwise the instruction. This is how it should be done.

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

#3

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