-
-
Save holocronweaver/4115551 to your computer and use it in GitHub Desktop.
Ben's replace_item function v2
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 replaces an existing index with a new one. | |
def replace_item(inventory,new_item): | |
for i,item in enumerate(inventory): | |
if item != new_item: | |
inventory[i] = new_item | |
return inventory | |
my_inv = [0]*26 | |
sword = "sword" | |
bow = "bow" | |
print replace_item(my_inv, sword) | |
print replace_item(my_inv, bow) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment