[Tutor] What's the invalid syntax?
Nathan Pinno
falcon3166 at hotmail.com
Tue Jul 25 03:24:49 CEST 2006
What's the invalid syntax?
[code]
from datetime import *
def menu():
print "(A)dd days to current date."
print "(F)ind how many days have passed since a date."
print "(E)xit."
def menu_choice():
choice = raw_input("Enter the letter of your choice: ")
return choice
def date1():
y1 = int(raw_input("Enter the year: "))
m1 = int(raw_input("Enter the month: "))
d1 = int(raw_input("Enter the day: "))
date1 = date(y1, m1, d1)
return date1
def date2():
y2 = int(raw_input("Enter the 2nd year: "))
m2 = int(raw_input("Enter the 2nd month: "))
d2 = int(raw_input("Enter the 2nd day: "))
date2 = date(y2, m2, d2)
return date2
print "Date Calculator"
print "By Nathan Pinno"
print
while 1:
menu()
menu_choice()
if choice == A:
date1()
days = int(raw_input("Enter the number of days to add: "))
date3 = date1 + days
print date(date3).isoformat(), " is the date ", days, " from today."
elif choice == F:
date1()
date2()
days = date2 - date1
print days, " days seperate " date2.isoformat(), " from ", date1.isoformat(), "."
elif choice = E:
break()
else:
print "That's not an option. Try again, please."
[/code]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060724/35ad8258/attachment.html
More information about the Tutor
mailing list