from datetime import datetime, timedelta
input1 = datetime.strptime(input(),"%d%b %Y")
input2 = datetime.strptime(input(),"%d%b %Y")
dates = (input1 + timedelta(idx )
for idx in range((input2 - input1).days+1))
res_sat = 0
res_sun = 0
# summing all weekdays
for day in dates:
#print(day.weekday())
if day.weekday() == 5:
res_sat+=1
elif day.weekday() == 6:
res_sun+=1
# printing
print("Total saturday's in range : " + str(res_sat))
print("Total sundays's in range : " + str(res_sun))
## If we want to print the total count only uncomment below line and comment above two lines.
#print(res_sat+res_sun)
Comments
Leave a comment