+ 1

Cleaner way to write this code

Hello masters of python. I wrote this myself but it looks kind of too long, I'm asking myself if there is a cleaner way to write something like this. Thanks in advance for your time: hour = int(input()) day = int(input()) # your code goes here if (hour <=24 and hour>=0 and day >=6 and day <=7 ): print("Closed") elif (hour>=10 and hour<=21 and day>=1 and day<=5): print ("Open")

23rd Nov 2020, 12:09 PM
Carlos Eduardo Marquez
Carlos Eduardo Marquez - avatar
2 Antworten
+ 2
NotAPythonNinja the non Ninja come to the rescue again, and with the best answer 👏. I'm officially a non ninja fan
23rd Nov 2020, 12:36 PM
Carlos Eduardo Marquez
Carlos Eduardo Marquez - avatar
+ 1
It should say open between days 1 and 5 and hour on these days from 10 to 21. On days 6 and 7 the whole time or on days from 1 to 5 between hour 22 and 09 should say close...
23rd Nov 2020, 12:25 PM
Carlos Eduardo Marquez
Carlos Eduardo Marquez - avatar