0

Boolean Error (test case 2)

Can anyone see why I’m getting an error with the input 20 and 4 saying “Closed”? with the following: hour = int(input()) day = int(input()) if 10<= hour <21 and 1>= day <=5: print("Open") else: print("Closed")

12th Mar 2021, 12:32 AM
Matt Odgers
2 Respostas
+ 2
if 10<=hour<21 and 1<=day<=5: not 1>=day<=5
12th Mar 2021, 12:42 AM
visph
visph - avatar
+ 1
Taking it step by step, Python evaluates the if condition as: 1. 10<=20<21 and 1>=4<=5 2. (10<=20 and 20<21) and (1>=4 and 4 <=5) 3. (True and True) and (False and True) 4. True and False 5. False Since the if condition evaluated to False, the else block is executed. Hence, 'Closed' is printed.
12th Mar 2021, 12:55 AM
Jolomi Tosanwumi