我试图让我的程序根据用户输入的小时返回不同的语句。如果我在前两个语句((hours<;6)和(hours<;=10)或(hours>;=6))之间输入一个小时数,它将返回正确的字符串,但如果我为小时输入任何大于10的值,它将不会返回该小时的预期字符串,但会继续重复第二个字符串。在
感谢任何帮助!在def food(hours, boolean):
if boolean == "True" or boolean == "true":
if (hours < 6):
return "no food"
elif (hours <= 10) or (hours >= 6):
return "breakfast, marmalade"
elif (hours <= 15) or (hours >= 11):
return "lunch, true,dessert"
elif (hours < 22) or (hours >= 15):
return "dinner, dessert"
else:
return "no food"
else:
if (hours < 6):
return "no food"
elif (hours <= 10) or (hours >= 6):
return "breakfast,coffee"
elif (hours <= 15) or (hours >= 11):
return "lunch, false"
elif (hours < 22) or (hours >= 15):
return "dinner"
else:
return "no food"
x = food(15, "true")
print(x)