Having problems with what should be a "no brainer" LC.
Code snippet below:
def daterange(start_date, end_date):
for n in range((end_date - start_date).days):
yield start_date + dt.timedelta(n)
def get_workdays_between_dates(start_date, end_date):
return [x in daterange(start_date, end_date) if x.date.weekday() in range(0,7)]
Python barfs a 'SyntaxError: invalid syntax error' when parsing function get_workdays_between_dates(). It looks ok to me though ...
What's wrong with the code?
What's x
? :) Yes, that's an invalid syntax, you are missing the for
part.
[x for x in daterange(start_date, end_date) if x.date.weekday() in range(0,7)]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With