Most popular tags

306 questions

415 answers


329 users

Most active Members
this week:

    Recent Badges

    Notable Question
    - smartin -

    How can i put multiple answers to an if statement?

    0 votes

    i want my if statement to have multiple answers without using an or statement, how is this possible??


    y_n=input("Do you want to play a game?")

    if y_n == "y" "yes" "yeah" "n" "no" "nah":



    asked Nov 4, 2016 in Python by anonymous

    1 Answer

    0 votes
    Best answer
    You can use ...
    If x in ("cat", "dog", "pig")

    Will match if x has any of the values cat, dog or pig.
    answered Nov 13, 2016 by smartin (10,770 points)
    selected Dec 2, 2016
    Welcome to Selby Computing Q&A, where you can ask questions and receive answers from other students in Computer Science.