Skip to content

Instantly share code, notes, and snippets.

@andreburto
Last active June 11, 2017 13:03
Show Gist options
  • Save andreburto/9013f87ec687127ad79179f9a27106e3 to your computer and use it in GitHub Desktop.
Save andreburto/9013f87ec687127ad79179f9a27106e3 to your computer and use it in GitHub Desktop.
Count the leap years since a couple was married.
import datetime, calendar
def find_leap_years_in_marriage(married_year):
current_year = datetime.datetime.now().year
return sum([1 for year in range(married_year, current_year) if calendar.isleap(year)])
if __name__ == '__main__':
import sys
leap_year_count = find_leap_years_in_marriage(int(sys.argv[1]))
print 'You have {yc} leap years between when you were married and this anniversary.'.format(yc=leap_year_count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment