-1

I built this function and don't understand, why it doesn't work:

def give_age_of(birthday):

    import datetime
    from dateutil.relativedelta import relativedelta

    aging = birthday
    totoday = datetime.date.today()
    age_of = relativedelta(totoday,aging).years

    return age_of
 File "<ipython-input-258-df8b9618ac1f>", line 5
    import datetime
    ^
IndentationError: expected an indented block
wjandrea
  • 23,210
  • 7
  • 49
  • 68

1 Answers1

0

Ok, so I got it, thanks to KlausD. The code that actually doesn't work is the following, but I found the solution myself already. I had to dedent the comment in line 1.

    # blablabla

def give_age_of(birthday):

    import datetime 
    from dateutil.relativedelta import relativedelta

    aging = birthday
    totoday = datetime.date.today()
    age_of = relativedelta(totoday,aging).years

    return age_of