Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Weekend Counter by Kurush
import datetime
def checkio(from_date, to_date):
count = 0
while from_date <= to_date:
if from_date.weekday() in [5, 6]: count += 1
from_date += datetime.timedelta(1)
return count
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio(datetime.date(2013, 9, 18), datetime.date(2013, 9, 23)) == 2, "1st example"
assert checkio(datetime.date(2013, 1, 1), datetime.date(2013, 2, 1)) == 8, "2nd example"
assert checkio(datetime.date(2013, 2, 2), datetime.date(2013, 2, 3)) == 2, "3rd example"
June 18, 2014
Comments: