Inventory for Text-Based Adventure -
Complete Lists & Dictionaries in Codecademy
Look at "14. It's Dangerous to Go Alone! Take This" in Codecademy
Rubric:
25 pts has inventory[]
25 pts .append
10 pts .remove
10 pts User has choice and can add and remove
10 pts User can choose to look at (print) inventory
+20 free points
# Be careful to use raw_input, not input! The video is for Python 3, and codecademy uses Python 2.7 so you must make sure to use raw_input!inventory=[]
HINT:
def startRoom():
global inventory
print ("The receptionist greets you and gives you a secret spy suitcase.")
print ("The receptionist gives you a cell phone.")
print("Would you like to put it in the suitcase?")
pickup=raw_input()
if pickup=="yes":
addToInventory("phone")
else:
print("You don't take the cell phone.")
print (inventory)
def addToInventory(item):
inventory.append(item)
startRoom()
Rubric:
25 pts has inventory[]
25 pts .append
10 pts .remove
10 pts User has choice and can add and remove
10 pts User can choose to look at (print) inventory
+20 free points
# Be careful to use raw_input, not input! The video is for Python 3, and codecademy uses Python 2.7 so you must make sure to use raw_input!inventory=[]
HINT:
def startRoom():
global inventory
print ("The receptionist greets you and gives you a secret spy suitcase.")
print ("The receptionist gives you a cell phone.")
print("Would you like to put it in the suitcase?")
pickup=raw_input()
if pickup=="yes":
addToInventory("phone")
else:
print("You don't take the cell phone.")
print (inventory)
def addToInventory(item):
inventory.append(item)
startRoom()