Search code examples
pythonraw-input

how to identify multiple keywords in raw_input? python


    if "sneak" or "assasinate" or "stealth" not in action:
        print"...cmon, you're a ninja! you can't just attack!"
        print "STEALTH, SNEAK ATTACKS, ASSASINATIONS!"
        print "The gods decide that you have come too close to loose now."
        print "they give you another chance"
        return 'woods'
    else:
        print "You throw a ninja star at a near by tree to distract the warlord,"
        print "you take out his legs, get him on the ground and have your blade to his neck"
        print "You take off his mask to stare into his eyes as he dies, and realise, it's your father."
        return 'the_choice'

this the bit of code i'm having a problem with. i'm new to python, and i need to know how i can identify more than one word given in raw_input. i can't figure out why that ^ doesn't work, but this does :

action = raw_input("> ")

if "body" in action:
    print "You hit him right in the heart like a pro!"
    print "in his last dying breath, he calls for help..."
    return 'death'

any help will be appreciated, many thanks


Solution

  • You can use the built-in function any() :

    any(x not in action for x in  ("sneak","assasinate","stealth"))