import datetime aDate = datetime.date(2015, 1, 1) b = 0 while aDate != datetime.date(2015,12,31): aDate = aDate + datetime.timedelta(days=1) if (aDate.month + aDate.day) <= 12: b = b + 1 print b