Reputation: 1
Looking help with the code below, it seems that adding m_Time on the first if statement makes the program run incorrectly. Just looking at the first if statement, the rest works as intended. Any help regarding this would be appreciated.
tick_Num = float(input("How many tickets are you buying? "))
day = input("What day do you want to watch the movie? Enter mon for Monday etc. ")
m_Time = int(input("What time is the movie? Enter 0000 to 2359: "))
if 200 <= m_Time <= 1600 and tick_Type == "child" and day != "sat" or day != "sun":
print("You should be in school, not at the movies.")
elif tick_Type == "child" and day == "mon" or day == "tue" or day == "wed":
total = 8 * tick_Num * 0.75
print("Total: $" + format(total,",.2f"))
elif tick_Type == "senior" and day == "mon" or day == "tue" or day == "wed":
total = 9 * tick_Num * 0.75
print("Total: $" + format(total,",.2f"))
elif tick_Type == "general" and day == "mon" or day == "tue" or day == "wed":
total = 10 * tick_Num * 0.75
print("Total: $" + format(total,",.2f"))
elif tick_Type == "child" and day == "thu" or day == "fri" or day == "sat":
total = 8 * tick_Num * 1
print("Total: $" + format(total,",.2f"))
elif tick_Type == "senior" and day == "thu" or day == "fri" or day == "sat":
total = 9 * tick_Num * 1
print("Total: $" + format(total,",.2f"))
elif tick_Type == "general" and day == "thu" or day == "fri" or day == "sat":
total = 10 * tick_Num * 1
print("Total: $" + format(total,",.2f"))
elif tick_Type == "child" and day == "sun":
total = 8 * tick_Num * 0.9
print("Total: $" + format(total,",.2f"))
elif tick_Type == "senior" and day == "sun":
total = 9 * tick_Num * 0.9
print("Total: $" + format(total,",.2f"))
elif tick_Type == "general" and day == "sun":
total = 10 * tick_Num * 0.9
print("Total: $" + format(total,",.2f"))
elif day == "mon" or day =="tus" or day == "wed":
total = 10 * tick_Num * 0.75
print("Total: $" + format(total,",.2f"))
elif day == "thu" or day =="fri" or day == "sat":
total = 10 * tick_Num * 1
print("Total: $" + format(total,",.2f"))
elif day == "sun":
total = 10 * tick_Num * 0.9
print("Total: $" + format(total,",.2f"))
else:
print("NO TICKET: invalid day")
Upvotes: 0
Views: 56
Reputation: 166
Assuming I identified your problem correctly, your first clause 200 <= m_Time <= 1600 and tick_Type == "child" and day != "sat" or day != "sun"
would always be True if day != 'sun'
is True because of the way Python calculates booleans. What I believe you want is something like this:
if 200 <= m_Time <= 1600 and tick_Type == "child" and day != "sat" and day != "sun":
...
Upvotes: 1