+ 1
Is there a better way to structure my code
Is there a better way (shorter) to code the boolean logic if-and in this code ; hour = int(input()) day = int(input()) # your code goes here if hour>=10 and hour<=20 and day>=1 and day<=5 : print ("Open") else : print ("Closed")
3 Respuestas
+ 8
Marc-Olivier Auger as ∆BH∆Y already mentioned: your code is ok. an alternative way of doing the conditional expression could be to use range like:
if hour in range(10,20+1) and day in range(1,5+1):
but this is not shorter or faster, maybe the readability is a bit better. but nothing what really matters.
+ 4
You can do
if 10<=hour<=20 and 1<=day<=5:
+ 1
Awesome thanks guys for your time !!