Advertisement
JkSoftware

Day 10 - Leap Year Challenge 2

Nov 15th, 2021
862
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def is_leap(year):
  2.   if year % 4 == 0:
  3.     if year % 100 == 0:
  4.       if year % 400 == 0:
  5.         return True
  6.       else:
  7.         return False
  8.     else:
  9.       return True
  10.   else:
  11.     return False
  12.  
  13. def days_in_month():
  14.   if month > 12 or month < 1:
  15.       return "Invalid Month"
  16.   month_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
  17.   if is_leap(year) and month == 2:
  18.       return 29
  19.   return month_days[month -1]
  20.  
  21.  
  22.  
  23. # Do NOT change any of the code below
  24. year = int(input("Enter a year: "))
  25. month = int(input("Enter a month: "))
  26. days = days_in_month(year, month)
  27. print(days)
  28.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement