Advertisement
greedydev

Untitled

Oct 18th, 2022
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. import datetime
  2.  
  3. def task2():
  4.     first_person = input("Enter dob and name of the first person in format DD/MM/YYYY-name: ").split("-")
  5.     second_person = input("Enter dob and name of the second person in format DD/MM/YYYY-name: ").split("-")
  6.  
  7.     first_dob = datetime.datetime.strptime(first_person[0], "%d/%m/%Y")
  8.     second_dob = datetime.datetime.strptime(second_person[0], "%d/%m/%Y")
  9.  
  10.     if first_dob == second_dob:
  11.         print(f"{first_person[1]} and {second_person[1]} are the same age.")
  12.     elif first_dob > second_dob:
  13.         print(f"{second_person[1]} is older.")
  14.     else:
  15.         print(f"{first_person[1]} is older.")
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement