This is probably very simple, but I am a beginner in python and I wanted to compare birthday dates by prompting a user to enter a date in MM-DD format. No year because year is current year (2011). It will then prompt the user to enter another date, and then the program compares it to see which one is first. Then it prints out the earlier day and it's weekday name.
Example: 02-10 is earlier than 03-11. 02-10 is on thursday and 03-11 is on friday
I just started learned modules and I know i'm supposed to use the datetime module, a date class and strftime to get the weekday name. I don't really know how to put it all together.
If someone can help me get started that would really help! I have some bits and pieces together:
import datetime
def getDate():
while true:
birthday1 = raw_input("Please enter your birthday (MM-DD): ")
try:
userInput = datetime.date.strftime(birthday1, "%m-%d")
except:
print "Please enter a date"
return userInput
birthday2 = raw_input("Please enter another date (MM-DD): ")
if birthday1 > birthday2:
print "birthday1 is older"
elif birthday1 < birthday2:
print "birthday2 is older"
else:
print "same age"
try
only once? You read two dates. I don't really understand your moves. You should first read a good Python-language tutorial. docs.python.org/tutorial/index.html – Maciej Ziarko