days_in_month = {1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}
days_in_month_leap = {1:31,2:29,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}
# for regular year
# accumulator pattern
days_in_previous_months = {}
sum = 0 # accumulator variable
for i in range(1,13):
days_in_previous_months[i] = sum
sum = sum + days_in_month[i]
print(days_in_previous_months)
# for leap year
# accumulator pattern
days_in_previous_months_leap = {}
sum = 0 # accumulator variable
for i in range(1,13):
days_in_previous_months_leap[i] = sum
sum = sum + days_in_month_leap[i]
print(days_in_previous_months_leap)
ds = input("Enter date in format MM/DD/YYYY: ")
d = ds.split('/')
month = int(d[0])
day = int(d[1])
year = int(d[2])
if month == 1:
ndays = day
else:
if year%4 == 0 and (year%100 !=0 or year%400 == 0):
ndays = day + days_in_previous_months_leap[month]
else:
ndays = day + days_in_previous_months[month]
print("The day number for " + ds + " is " + str(ndays))
print(d[2])
"hello " + "johnny"