Skip to content

Instantly share code, notes, and snippets.

@LewkyB
Created September 18, 2014 22:52
Show Gist options
  • Save LewkyB/5bcca222c6bb788c44de to your computer and use it in GitHub Desktop.
Save LewkyB/5bcca222c6bb788c44de to your computer and use it in GitHub Desktop.
maxlab2 revised
#Luke , Python , 9/17/2014
month = raw_input("Month: ").lower() # asks what month it is and forces the entry to be in lower case so that it matches with my list entries
# when you put things in "" it makes it print
year = int(raw_input("Year: ")) # asks for year and the int() requires the entry to be a number
month30 = ["september", "april", "june", "november"] # all the months with 30 days
month31 = ["january", "march", "may", "july", "august", "october", "december"] # all months with 31 days
month29 = ["february"] #month with 28 /w no leap and 29 with leap
# elif means "else if"
if month in month30: # if raw input is in month30 list
print "30 days" #then print 30 days
elif month in month31: # if raw input is in month31 list
print "31 days" #then print 31 days
elif month in month29: # if raw input is in month29
if year % 4 == 0 and year % 100 != 0 or year % 400 == 0: #if year input is divisible by 4 and year is not divisble by 100 or year is divisble by 400
print "29 days" #then print 29 days
else: # if nothing is or is not divisible by the numbers in the above formula
print "28 days" #then print 28 days
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment