Last active
June 11, 2017 13:03
-
-
Save andreburto/9013f87ec687127ad79179f9a27106e3 to your computer and use it in GitHub Desktop.
Count the leap years since a couple was married.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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