Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Dates and Times in Python (2014) Dates and Times Far Away

What am I doing wrong?

I keep getting the message Bummer: Try again! i don't know what i am doing wrong.

far_away.py
import datetime
now = datetime.datetime.now()
far_away = datetime.timedelta()
now + far_away
return

Can you post your updated code?

3 Answers

The instructions ask you to write a function called far_away that takes a timedelta argument. To create a function with a parameter use the following syntax:

def my_function(myparam):

The function should return datetime.datetime.now() + timedelta so you would have a return statement like this if your parameter was named timedelta:

    return datetime.datetime.now() + timedelta

i still get an error message

The time delta will be passed in to your function so you need a parameter to handle this. Below the parameter is named delta. I would also move now into the function.

import datetime

def far_away(delta):
    now = datetime.datetime.now()
    return now + delta

So the "delta", for the time delta argument is built in?

import datetime

now = datetime.datetime.now()

def far_away():

far_away = datetime.timedelta()

return now + far_away