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 trialEmily Strobl
5,429 PointsWhat am I doing wrong?
I keep getting the message Bummer: Try again! i don't know what i am doing wrong.
import datetime
now = datetime.datetime.now()
far_away = datetime.timedelta()
now + far_away
return
3 Answers
KRIS NIKOLAISEN
54,971 PointsThe 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
Emily Strobl
5,429 Pointsi still get an error message
KRIS NIKOLAISEN
54,971 PointsThe 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
Luke Tate
Courses Plus Student 2,256 PointsSo the "delta", for the time delta argument is built in?
Emily Strobl
5,429 Pointsimport datetime
now = datetime.datetime.now()
def far_away():
far_away = datetime.timedelta()
return now + far_away
KRIS NIKOLAISEN
54,971 PointsKRIS NIKOLAISEN
54,971 PointsCan you post your updated code?