0

What am I doing wrong?

hour = int(input()) day = int(input()) if hour >= 10 and hour <= 21: if day > 0 and day < 6: print("Open") else: if hour < 10 or hour > 21: if day == 6 or day == 7: print("Closed")

22nd Mar 2021, 6:43 PM
Alain Wannamaker
Alain Wannamaker - avatar
8 Antworten
+ 1
# hour should be between 10 <= and <= 21, to write both condition at once: hour = int(input()) day = int(input()) if day < 6 and 10 <= hour <=21: print("Open") else: print("Closed")
23rd Mar 2021, 5:02 PM
visph
visph - avatar
+ 1
Hi! You not pass test #3, where hour - 13, day - 6 -> no output. Can you solve this?
22nd Mar 2021, 7:10 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
First problem. Your range of days goes from 0 to 7 inclusive, which is eight days. Tidy up your if / else statement. you know that the end result is open or closed, so specify the opening hours only. when your if statement is not true (open), the else statement will commence. So if not open _> else: print("closed")
22nd Mar 2021, 7:10 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
days can start with both zero and one inclusive, this does not affect anything, because 0 and below will never be entered.
22nd Mar 2021, 7:13 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
explanations in comments, and other shortest ways to write it... https://code.sololearn.com/cnBG5pNVaZjR/?ref=app
22nd Mar 2021, 7:18 PM
visph
visph - avatar
+ 1
Thankyou everyone for the help and in-depth explinations
23rd Mar 2021, 5:20 PM
Alain Wannamaker
Alain Wannamaker - avatar
0
After I cut out the closed hours it works on everything other that input 13 & 6
23rd Mar 2021, 3:01 PM
Alain Wannamaker
Alain Wannamaker - avatar
0
hour = int(input()) day = int(input()) if day < 6 and hour >= 10 <=21: print("Open") else: print("Closed") Won't clear test 4. Ugh.. do they lock some of the tests performed on it to make you do bug evaluations?
23rd Mar 2021, 3:22 PM
Alain Wannamaker
Alain Wannamaker - avatar