Hi,

Am a beginner in python. Wrote this program based on the doomsday algorithm to calculate what day of the week corresponds to an inputted date.... at the moment idle rejects the program citing'march4 is not defined'.(line 23) Am i not clearly defining it there??

Please help!!

Program text:

#Doomsday Algorithm

#A program which calculates the day of the week corresponding to a user inputted numerical date,

#between the years 1900-2099.

import string

#Get the Date;

dateStr=raw_input("Please input a date (dd/mm/yyyy):")

#Split into Components;

dayStr, monthStr, yearStr = string.split(dateStr, "/")

if [int(yearStr)] >= 2000 :

y = (float(yearStr)-2000)

doomsday = 3 + ((y)/12) + ((y)%12) + ((y)%12/4)%7

z = float(yearStr[2:4])

if z%4 == 0 :

doomsday + 3 == march4

else:

doomsday + 4 == march4

if [int(monthStr)] == 1 :

x = abs([int(dayStr)-(31 + doomsday)])

elif [int(monthStr)] == 2 :

x = abs([int(dayStr)-doomsday])

elif [int(monthStr)] == 4 :

x = abs([int(dayStr)-4])

elif [int(monthStr)] == 5 :

x = abs([int(dayStr)-35])

elif [int(monthStr)] == 6 :

x = abs([int(dayStr)-36])

elif [int(monthStr)] == 7 :

x = abs([int(dayStr)-66])

elif [int(monthStr)] == 8 :

x = abs([int(dayStr)-97])

elif [int(monthStr)] == 9 :

x = abs([int(dayStr)-107])

elif [int(monthStr)] == 10 :

x = abs([int(dayStr)-138])

elif [int(monthStr)] == 11 :

x = abs([int(dayStr)-168])

elif [int(monthStr)] == 12 :

x = abs([int(dayStr)-199])

if x < 7:

distance == x

elif x == 7:

distance == 0

elif x > 7:

distance == 7%x

else :

y= (float(yearStr)-1900)

doomsday = 4 + (abs(y)/12) + (y%12) + (y%12/4)%7

z= float(yearStr[2:4])

if z%4 == 0 :

doomsday + 3 == march4

else:

doomsday + 4 == march4

if [int(monthStr)] == 1 :

x = abs([int(dayStr)-(31 + doomsday)])

elif [int(monthStr)] == 2 :

x = abs([int(dayStr)-doomsday])

elif [int(monthStr)] == 4 :

x = abs([int(dayStr)-4])

elif [int(monthStr)] == 5 :

x = abs([int(dayStr)-35])

elif [int(monthStr)] == 6 :

x = abs([int(dayStr)-36])

elif [int(monthStr)] == 7 :

x = abs([int(dayStr)-66])

elif [int(monthStr)] == 8 :

x = abs([int(dayStr)-97])

elif [int(monthStr)] == 9 :

x = abs([int(dayStr)-107])

elif [int(monthStr)] == 10 :

x = abs([int(dayStr)-138])

elif [int(monthStr)] == 11 :

x = abs([int(dayStr)-168])

elif [int(monthStr)] == 12 :

x = abs([int(dayStr)-199])

if x < 7:

distance == x

elif x == 7:

distance == 0

elif x > 7:

distance == 7%x

day = distance + march4

days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]

dayStr = days[int(day)]

print "The day corresponding to the date," ,dateStr, "is:", dayStr