This question already has an answer here:
I'm trying to write a small game that will ask to make a choice and then call a different function according to the choice made. Below I have the main function that gets called when I open up the program.
My problem is that when the program runs and I put in one of the options, the program will only go through the first if-statement
.
So, if I put 2
or school
into the raw_input
, or any other option, my program still calls the work
function.
def bedroom():
print "Good morning! Today is full of possibilities. What do you want to do?"
print """
1. Go to work
2. Go to school
3. Go on an adventure
4. Relax with a friend
"""
choice = raw_input("| ")
if "1" or "work" in choice:
print "Great! Making money and being diligent is a brilliant thing to do with life!"
work()
elif "2" or "school" in choice:
print "Wonderful! You can never learn enough."
school()
elif "3" or "adventure" in choice:
print "Oh, yay! Adventures make life exciting!"
adventure()
elif "4" or "relax" or "friend" in choice:
print "It's importanat to not exhaust yourself. Relaxing will help you refocus."
relax()
else:
print "Stop being creative! That wasn't an option."
bedroom()
Any ideas as to why it's not considering the rest of the if-else
statement?
Aucun commentaire:
Enregistrer un commentaire