""" ANTONIO CLARKE Practice with lists and dictionaries for a potential roguelike game. """ inventory = {'backpack' : ['apple', 'old key', 'rope'], 'pockets' : ['crumpled paper']} def check_inv(): for item in inventory: print inventory[item] return True check_inv() itemToLose = raw_input('Choose an item to get rid of from your backpack. ') if inventory['backpack']['backpack'.index(itemToLose)] == "": inventory['backpack'].remove(itemToLose) print "\nA %s was removed from your backpack." % (itemToLose) check_inv() #else: # print "Sorry, you don't seem to have a %s in your backpack." % (itemToLose)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question