Hi I am very new to Python and I'm in the process of learning about lists.
Im writing a little puzzle text game that requires you to use basic commands to move from room to room (function to function). Some rooms have traps and they require an item to remove the trap. E.G A bear in a room requires you to first find the honey and then give it to the bear. I also understand how to .remove() and .append() the list.
I've created 2 lists:
inventory = ["Honey"]
trap = ["Bear"]
When I enter the room with the bear and I have the honey, awesome I can pass, but how do I make a loop or #Something# that checks the 'trap' list so that if the "bear" element isn't in the list they don't require the honey to pass through as obviously i remove the "honey" from the 'inventory' list as soon as they use it on the bear. The theory is that if they exit the room and want to re-enter they don't require the honey again.
I guess my understanding of this is something like this, also assume you already found the honey:
def room1()
print "You are in ROOM 1"
if #item is not in list# and #bear is not in the room#:
room2()
elif #item is in the bag#:
print "You give the honey to the bear, and it is distracted"
inventory.remove("Honey")
trap.remove("Bear")
room2()
else:
print "You die to the bear"
exit()
I would really appreciate any advice or even a different approach to this issue. Thanks so much!