0

Need help with if else statements. Everytime I run it the elif is not being recognized.

Wday = 17 

Wtues = 12 

Wend = 20 

day = input("Input the day of the drama: ") 
num = int(input("How many tickets? ")) 

if day == "monday" or "wednesday" or "thursday" or "friday":
    print(f"Total ticket cost is = ${num * Wday}") 
elif day == "tuesday": 
    print(f"Total ticket cost is = ${num * Wtues}") 
elif day == "sunday" or "saturday": 
    print(f"Total ticket cost is = ${num + Wend}")
else:
    print("Invalid.")
    exit()

The result when I run it is:

Input the day of the drama: Tuesday

How many tickets? 1

Total ticket cost is = $17

(The answer should be $12 not $17)

Jode
  • 1
  • 1
  • the first "if" line is equivalent to `if (day == "monday") or bool("wednesday") or bool("thursday") or ...` and `bool("non-empty string")` is always true, so the line is basically `if False or True or True or True` – Aaron Oct 04 '22 at 03:22
  • 1
    Python is not English. `if day == "monday" or day == "wednesday"`, etc. is required, not `if day == "monday" or "wednesday"`. You can use `if day in ("monday", "wednesday, "thursday", friday")` however. – Mark Tolonen Oct 04 '22 at 03:22
  • 1
    Your comparison is wrong, your are comparing "Tuesday" with "tuesday". Add a line ```day.lower()``` to put the input data in lowercase. – Gui Reis Oct 04 '22 at 03:30
  • add `day = str(input("Input the day of the drama: ")).lower()`, and turn to if statements `day == ("monday" or "wednesday" or "thursday" or "friday")` – uozcan12 Oct 04 '22 at 09:03

0 Answers0