Most popular tags

304 questions

412 answers

70 comments

329 users

Most active Members
this week:
  1. 15boyntonc - 2 points
  2. 15husbando - 1 points
  3. 15bratbyf - 1 points

Recent Badges

100 Club
- 15arnoldr -
Verified Human
- 15arnoldr -
Nice Question
- 14scotta -
Verified Human
- 15harrisonb -
Good Question
- smartin -
Nice Question
- 14scotta -
Nice Question
- 14scotta -
Nice Question
- 14scotta -
Nice Question
- 14gregoryj -
100 Club
- 15bratbyf -
100 Club
- 15bellc -
100 Club
- 15matereker -
Verified Human
- 15bellc -
Verified Human
- 15bratbyf -
100 Club
- 15agard -
Verified Human
- 15matereker -
Verified Human
- 15agard -
100 Club
- 15gardnerj -
100 Club
- 15houghm -
100 Club
- 15almondi -
100 Club
- 15huddlestonj -
Verified Human
- 15houghm -
Verified Human
- 15almondi -
Verified Human
- 15huddlestonj -
Verified Human
- 15gardnerj -
Verified Human
- 15husbando -
100 Club
- 15wilkinsona -
100 Club
- 15wearh -
100 Club
- 15Barfields -
100 Club
- 15harrisonb -

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 14goldinga (710 points)

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 (16,520 points)
selected Dec 2, 2016 by 14goldinga
Welcome to Selby Computing Q&A, where you can ask questions and receive answers from other students in Computer Science.
...