0

I am confused on how to begin this problem. I need to compare two ages' birthdays and the function needs to say who is older and if they have the same birthday the output should say same age. However, I am confused on how to compare the dates. for example, the function needs to call (Susan, '1989-02-17") and compare but I don't know how to code in the date. This is what I have done so far.

def who_is_younger(person, person2):

    date1 = 

    date2 =

    if date1 == date2:

        return("Same Age")

    elif date1 > date2:

        return person[0]

    else:

        return person2[0]
rdas
  • 20,604
  • 6
  • 33
  • 46

1 Answers1

1

You can do the following:

def who_is_younger(person, person2):

    date1 = time.strptime(person[1], "%Y-%m-%d")

    date2 = time.strptime(person2[1], "%Y-%m-%d")

    if date1 == date2:

        return("Same Age")

    elif date1 > date2:

        return person[0]

    else:

        return person2[0]

Also have a look at the answer here