0
Elif priblem python
hour = int(input()) day = int(input()) # your code goes here if hour >= 10 and hour <= 21: elif day != 6 or day != 7: print("Store is open") else: print("Store is close") Error...expecting an indented block...
6 Antworten
+ 6
you doesn't put any statement after the first 'if' condition: that's where and what is expected ^^
+ 1
You put the elif statement inside the if statement, making the IndentError to happen.
+ 1
I guess you should do:
if hour>=10 and hour<=21 and day!=6 and day!=7:
...
else:
...
notice the 'and' instead of 'or' between day condition ;)
+ 1
Mayank
See this article to know about "Indentation Error" in python
https://www.educba.com/indentation-error-in-python/
You need to check like this:
if(10 <= hour <= 21) and (day <= 5):
#Open
else:
#Closed
Why day <= 5? Because store opens only 5 days.
And hours between 10 and 21 so we can check (10 <= hour <= 21)
Also you have printed wrong value. There should be Open or Closed
+ 1
Thank you all.
0
hour = int(input())
day = int(input())
if hour >= 10 and hour <= 21:
if day != 6 or day != 7:
print("Store is open")
else:
print("Store is close")
# here is your solution...
Don't use elif in if conditional block, it will give syntax error..!!
Also your code under conditional blocks was not indented properly...