+ 1
Why doesnt it output "closed"?
Python core 21.2 problem, test case #3 shows no output. hour = int(input()) day = int(input()) # your code goes here if day >= 1 and day <=5: if hour >= 10 and hour <= 21: print("Open") else: print("Closed")
5 Respuestas
+ 3
nabeer zahed chowdhury The problem is with your else statement. The else clause should execute whenever any of the above if statements (chained) won't execute. You can make it work by combining all the conditions with the 'and' keyword instead of chaining it:
if 0 < day < 6 and 9 < hour < 22: ...
else: ...
# I hope that this helps you with your query. Happy coding!
+ 2
Delicate Cat yep, but in test case #3, it doesn’t satisfy the if statement therefore should go to else statement. But its not doing that
Also, why does the chaining And not chaining if statements cause different outputs.
Appreciate ur help
+ 2
Well im not aware actually, but after you mentioned them, I found those online and probably I'll learn them adequetly in future...
Thanks
+ 1
Could you post the description of the assignment?
0
nabeer zahed chowdhury Hmm, you may have a look at the corrected version of your code:
hour = int(input())
day = int(input())
print("Open" if 0 < day < 6 and 9 < hour < 22 else "Closed")
# Note: I'm posting this assuming that you're aware of chained conditionals and the ternary statement in Python