Lesson 8: "What year were you born?" - Strings and Dates

posted Dec 19, 2018, 8:07 AM by Attila Lengyel
age = int(input("How old are you?:"))
year = 2018
birth = year - age
print("Where you born in", birth, "?")

import time, datetime

print(datetime.date.today())

today = str(datetime.date.today())
print(today)

month = today[5] + today[6]
print(month)
day = today[8] + today[9]
print(day)

question = "Is your birthday before " + month + "/" + day + "?"
answer = input(question)
if answer == "no":
birth = year - age - 1
print("Where you born in " + str(birth) + ".")
Comments