-2
day = input("Enter a Day:")
is_vacation = input("Is this a vacation?")

if((day == 'Monday', 'Tuesday', 'Wednesday', 'Thrusday', 'Friday') and is_vacation == 'No'):
    print('False')
elif((day == 'Saturday', 'Sunday') and is_vacation == 'Yes'):
    print('True')

If my input is:

day = Monday
is_vacation = Yes

Output:

True

I have used and the operator in first if block it should be false.

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
  • I'm guessing you came from something like JavaScript or Java: you don't need brackets around the `if` statement, Python doesn't need it. – Qwerp-Derp Jul 26 '17 at 01:56
  • wilusdaman answer is correct. I also suggest that you use one case so that way your input will never mismatch the array. So make everything you are comparing either lowercase or uppercase by using `.lower()` or `.upper()` – Marcello B. Jul 26 '17 at 02:02
  • Only the second condition actually matters (e. g. to the right side of `and`). With the first one you are creating a tuple, either `(True, 'Tuesday', 'Wednesday', ...)` or `(False, 'Tuesday', 'Wednesday', ...)`, etc. - doesn't matter, a non-empty tuple always evaluates to `True` in conditional expressions. – Headcrab Jul 26 '17 at 02:46

1 Answers1

0

You want to check for membership rather than equality:

if day in {'Monday', 'Tuesday', ... } and is_vacation  == 'No':
    ...

day in {...} will evaluate to True if day is equal to anything inside the set (that is, if the value of day is in the set).

wbadart
  • 2,583
  • 1
  • 13
  • 27