lundi 26 octobre 2015

Python only executes one if statement

I am extremely new at python and programming in general so pardon if the answer is obvious. I am trying to write a program that will tell you what day Easter falls on through a range of years. I am running into a problem with my if statements. If the year is one of the years specified in the first if statement, it will not execute the second if statement even if day > 31.

year = int(input('Input a year: '))
a = year % 19
b = year % 4
c = year % 7
d = (19 * a + 24) % 30
e = (2 * b + 4 * c + 6 * d + 5) % 7

day = 22 + d + e

month = 'March'

if year == 1954 or year == 1981 or year == 2049 or year == 2076:
           day = day + 7

if day > 31:
           day = day - 31
           month = 'April'

print('Easter is on', month, day)

Aucun commentaire:

Enregistrer un commentaire