Skip to content

Instantly share code, notes, and snippets.

@DreamPhage
Created November 20, 2012 01:11
Show Gist options
  • Save DreamPhage/4115300 to your computer and use it in GitHub Desktop.
Save DreamPhage/4115300 to your computer and use it in GitHub Desktop.
replace_item function
#this function adds an item to the inventory if it is not full
def add_item(inventory, new_item):
if len(inventory) < 12:
inventory.append(new_item)
print inventory
else:
print "Your inventroy is full."
#this function removes an item from the inventory
def remove_item(inventory, del_item):
ask_user = raw_input("Do you want to remove this item? Y/N ")
for i, del_item in enumerate(inventory):
if ask_user == "Y" or ask_user == "y":
inventory.pop(i)
print inventory
else:
print "Okay, then."
print inventory
break
my_inv = []
sword = "sword"
bow = "bow"
add_item(my_inv, sword)
add_item(my_inv, bow)
remove_item(sword)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment