I want to define a function called sleep_in(weekday, vacation). The parameter weekday is True if it is a weekday, and the parameter vacation is True if we are on vacation. We sleep in if it is not a weekday or we're on vacation.
sleep_in(False, False) → True
sleep_in(True, False) → False
sleep_in(False, True) → True
sleep_in(True, True) → True
here's the function I defined
def sleep_in(weekday, vacation):
match (weekday, vacation):
case (False, False):
return True
case (True, False):
return False
case (False, True):
return True
case (True, True):
return True
but I get the following error:
invalid syntax (line 2)
can anyone tell me what's wrong with my code?
Edit:
Here's my full code in Jupiter Notebook!
Block of Code
You have not followed the writing rules. You should leave a space the size of a tab.
def ...():
match(...):
case(...):
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.