samedi 25 juillet 2015

Designating a Boolean as true from a raw_input string?

I have a simple if elif else statement that relies upon the input of the user.

options = ['Try to jump the gap', 'Go back to the entryway']
print "You can:"
for x in options:
    print "\t:>%s" % x
choice = raw_input("What do you do?")
if  'try' in choice:
    print "You try to jump the gap and fail."
    print "You fall into the pool of acid while shrieking in pain."
    print "You dissolve"
    dead()
elif 'go' in choice:
    change()
    entrywaymain()
else:
    unknown()
    change()
    poolroomclosed()

The code works when the user inputs just 'try' or 'go'. However, if the user inputs the full statements, either "try to jump the gap' or 'go back to the entryway', they will always get the if value and will die. So, how do I code so that the boolean will activate with only word from that string in the user input.

Aucun commentaire:

Enregistrer un commentaire