I have been trying to convert my code from java to python and I come across this issue. I am trying to make a calendar and everything I input the month and year, I come across this issue that I do not know what is means.
May you guys help me out?
Traceback (most recent call last):
File "/Users/macbook/Documents/Untitled.py", line 41, in <module>
main()
File "/Users/macbook/Documents/Untitled.py", line 30, in main
m, y = eval(input("Enter the month, and year (separated by spaces): "))
File "<string>", line 1
12 2013
^
SyntaxError: unexpected EOF while parsing
My code:
#------------------------------------------------------------------------
def isLeapYear():
if((year % 4 == 0) and (year % 100 != 0) or (year % 400 == 0)):
return true
else:
return false
#---------------------------------------------------------------------
def dayOfWeek(mon, day, year):
if(mon < 3):
year = year-1
wy = 3 + year + (year/4) - (year/100) + (year/400)
wm = int(2.6 * ((mon+9 % 12) +0.5))
wd = day-1
return (wd + wm + wy) % 7
#---------------------------------------------------------------------
def daysInMonth(month, year):
if(month ==4 or month ==6 or month ==9 or month==11):
return 30
elif(month==2):
if(isLeapYear(year)):
return 29
else:
return 28
else:
return 31
def main():
m, y = eval(input("Enter the month, and year (separated by spaces): "))
print("Sun Mon Tue Wed Thu Fri Sat\n")
i=0
while(i<dayOfWeek(m,1,y)):
print(" ")
i=i+1
d=1
while(d <= daysInMonth(m,y)):
print(d)
if(dayOfWeek(m,d,y) == 6):
print("\n")
d=d+1
main()