Hi I need Help with Boolean logic 2 coding challenge. The code below works with all but one case and I can't figure it out. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Hi I need Help with Boolean logic 2 coding challenge. The code below works with all but one case and I can't figure it out.

hour = int(input()) day = int(input()) # your code goes here #You need to create a program that outputs whether a store is Open or Closed, based on the hour and the day of the week. #The store is open on all days from 10 to 21, except Saturday and Sunday. #You need to take the hour and the day of the week as input. #The day of the week is represented as an integer (1 for Monday, 2 for Tuesday, etc.) #Sample Input: #15 #4 if day >= 1 and day <= 5: if hour > 9 and hour < 21: print("Open") else: print("Closed")

7th Dec 2020, 11:40 AM
Fast
8 Answers
+ 3
if day >= 1 and day <= 5: if hour >=10 and hour <= 21: print("Open") else: print("Closed") else: print("Closed")
7th Dec 2020, 12:01 PM
Yasara hasini
+ 2
From the description of oppening hours should be if hour >= 10 and hour <= 21:
7th Dec 2020, 11:47 AM
JaScript
JaScript - avatar
+ 1
If you input day in the range 1-5 and hour=21 your code will output nothing. But it must output "open". Also if the day is in the range 1-5 and the hour is not in the range 10-21 then your code will output nothing. It should output "closed". I think it is the problem with your test case.
7th Dec 2020, 11:47 AM
Yasara hasini
+ 1
hour = int(input()) day = int(input()) # your code goes here if hour >= 10 and hour <=21 and day !=6 and day !=7: print("Open") else: print("Closed")
10th Sep 2021, 10:16 PM
Kevin
0
Thank you but it still is not working even with JaScript's code. Also if the hour is at 21 wouldn't it be Closed and not Open?
7th Dec 2020, 11:52 AM
Fast
0
I think you forgot to add an else statement inside. hour = int(input()) day = int(input()) if day >= 1 and day <= 5: if hour >= 10 and hour <= 21: print('Open') else: print('Closed') else: print('Closed')
7th Dec 2020, 12:02 PM
noteve
noteve - avatar
0
Thank you all. Didn't know I needed an else statement inside. Does this mean with nested if statements I also need nested else statements?
7th Dec 2020, 12:06 PM
Fast
0
It still depends on the problem. if (day >= 1 and day <= 5) and (hour >= 10 and hour <= 21) : print('Open') else: print('Closed') In shorter code, it will be like this☝.
7th Dec 2020, 12:07 PM
noteve
noteve - avatar