python if-else语句中的多变量问题

python if-else语句中的多变量问题,python,if-statement,Python,If Statement,查看下面代码的帮助,似乎在第一个if语句中添加m_时间会导致程序运行不正确。只要看一下第一个if语句,其余语句就可以正常工作。任何有关这方面的帮助都将不胜感激 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

查看下面代码的帮助,似乎在第一个if语句中添加m_时间会导致程序运行不正确。只要看一下第一个if语句,其余语句就可以正常工作。任何有关这方面的帮助都将不胜感激

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")
tick_Num=float(输入(“您要买多少张票?”)
day=输入(“您想在哪一天看电影?输入周一等”)
m_Time=int(输入(“电影是什么时候?输入0000到2359:”)

如果200假设我正确识别了您的问题,那么您的第一个子句
200“运行不正确”是什么意思?@FrankYellin它在我输入时运行不正确:Senior,1,mon,600。它不应该基于输入运行第一个if语句,但出于某些原因仍然运行。运算符优先级…您不应该为每个可能的条件组合编写
elif
。您应该创建类似于
{'child':8,'senior':9,'general':10}
的字典,并从中获取价格的因素。
if 200 <= m_Time <= 1600 and tick_Type == "child" and day != "sat" and day != "sun":
...