Created
November 20, 2012 01:11
-
-
Save DreamPhage/4115300 to your computer and use it in GitHub Desktop.
replace_item function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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