Python代码未给出正确的结果

Python代码未给出正确的结果,python,Python,我对Python中的这段代码有问题。我需要把时间改成军事时间吗,怎么改?我的代码没有返回正确答案 问题是: 小时=3 分钟=45 #Around Georgia Tech, there are plenty of places to get a #late night bite to eat. However, they have different hours, #so when choosing where to go, you have to think about who's #stil

我对Python中的这段代码有问题。我需要把时间改成军事时间吗,怎么改?我的代码没有返回正确答案

问题是: 小时=3 分钟=45

#Around Georgia Tech, there are plenty of places to get a
#late night bite to eat. However, they have different hours,
#so when choosing where to go, you have to think about who's
#still open!
#
#Imagine you're choosing between the following restaurants:
#
# - Barrelhouse: Closes at 11:00PM
# - Taco Bell: Closes at 2:00AM
# - Cookout: Closes at 3:00AM
# - Waffle House: Never closes. Ever.
#
#Assume that this list is also a priority list: if Barrelhouse
#is open, you choose Barrelhouse. If not, you choose Taco Bell
#if it's open. If not, you choose Cookout if it's open. If
#not, you choose Waffle House.
#
#However, there are two wrinkles:
#
# - We're using 12-hour time.
# - hour will always represent a time from 10PM to 5AM.
#
#That means that if hour is 10 or 11, it's PM; if hour is
#12, 1, 2, 3, 4, or 5, it's AM. This will make your reasoning
#a little more complex. You may assume that all four
#restaurants open later than 6AM, though, so you don't have
#to worry about opening time, just closing time.
#
#Add some code below that will print what restaurant you'll
#go to based on the current values of hour and minute.
我的代码在这里

#Add your code here!

if hour == 12 and hour <= 5 and hour >= 1:
    print("Taco Bell" , "Cookout", "Waffle House")
elif hour > 5 and hour < 11:
    print("Waffle House" , "Barrelhouse")
#在此处添加您的代码!
如果小时=12且小时=1:
印刷品(“塔可钟”、“烹饪”、“华夫饼干屋”)
elif小时>5小时和小时<11小时:
印刷品(“华夫饼干屋”、“桶屋”)

您应该有以下流程来获取餐厅列表

list=[]

list.append("Waffle House")
if hour<=2 or hour>=6 :
    list.append("Taco Bell")

if hour<=3 or hour>=6:
    list.append("Cookout")

if hour<=11 and hour>=6:
    list.append("Barrelhouse")    

print(list)
list=[]
列表。附加(“华夫饼干屋”)
如果小时=6:
列表。附加(“塔可钟”)
如果小时=6:
列表。附加(“烹饪”)
如果小时=6:
列表。附加(“酒吧间”)
打印(列表)
如果小时数大于6小时且小时数小于11小时:
印刷品(“桶屋”)
elif(小时>6小时<12小时)或(小时>=12小时<13小时)或(小时>=1小时<2小时):
印刷品(“塔可钟”)
elif(小时>6小时<12小时)或(小时>=12小时<13小时)或(小时>=1小时<3小时):
打印(“烹饪”)
其他:
印刷品(“华夫饼干屋”)

这种逻辑毫无意义。如何使
hour
等于
12
,同时小于
5
?同意-重新考虑你的条件陈述,尽管这是问题的一部分,但你接受的答案和代码示例不使用餐厅的优先级。他们只是提供了一个开放餐厅的列表。欢迎来到Stack Overflow!只有代码的答案没有特别的帮助。请简要说明此代码如何解决此问题。
if hour > 6 and hour < 11:
    print("Barrelhouse")
elif (hour > 6 and hour < 12) or (hour >= 12 and hour < 13) or (hour >= 1 and hour < 2):
     print ("Taco Bell")
elif (hour > 6 and hour < 12) or (hour >= 12 and hour < 13) or (hour >= 1 and hour < 3):
    print ("Cookout")
else:
    print("Waffle House")