Why my code doesn't work


Who knows why my code doesn’t work online, but can run well in IDLE? help

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’


Your code here

inventory[‘pocket’] = [‘seashell’,‘strange berry’,‘lint’]

del inventory[‘backpack’]
inventory[‘gold’] = inventory[‘gold’]+50

above code can pass the test. good luck


Could you provide the link of the exercise ??




I have fixed this problem, thank you.


May i suggest you re-edit your Original post
then selecting the code
and click on :Preformatted text </> Button
Your code will Not being interpreted by the editor
and therefor would be more readable…
try it…

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'

# Your code here
inventory['pocket'] = ['seashell','strange berry','lint']

del inventory['backpack']
inventory['gold'] = inventory['gold']+50


The link you gave returns a HTTP 404 error !!!


Your code is awesome. Thank you for your suggestion. Pretty cool. Thanks a lot.


It was the code from your post…
please re-edit your Original post.


Ok, I just re-edited it for sharing with everyone. it works.


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