I have been searching for a clarified answer on this. I have read many threads and other websites about using datetime, but how can I build a simple program that prompts a user for two certain dates, and then calculate the difference between those dates? I am stuck on figuring out how to get the month and days.
This is what I have so far:
print ("How old will you be when you graduate?")
print ("If you want to know, I'll have to ask you a few questions.")
name = input('What is your name? ')
bYear = int(input("What year were you born? "))
print ("Don't worry. Your information is safe with me.")
bMonth = int(input("What month were you born? "))
bDay = int(input("How about the day you were born? "))
print ("Fantastic. We're almost done here.")
gYear = int(input("What year do you think you'll graduate? "))
gMonth = int(input("What about the month? "))
gDay = int(input("While you're at it, give me the day too. "))
age = gYear - bYear
if bMonth > gMonth:
age = age - 1
aMonth =
if bMonth == gMonth and bDay > gDay:
age = age - 1
print(name, 'you will be', age, 'years old by the time you graduate. Thanks for the information.')
I am just beginning to use Python, but it's seems pretty simple just coming in. So, for example I want to prompt the user for the year they were born, the month they were born, and the day they were born. Then I want to prompt the user for the year they will graduate, the month they will graduate, and the day they will graduate. Then I want the program to calculate the difference between those dates and output the age of the person in years, months, and days.
For example
BORN AUGUST 23, 1995
WILL GRADUATE: JUNE 11, 2018
AGE AT GRADUATION : 22 YEARS 9 MONTHS AND 18 DAYS