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


Aaron Banerjee
Aaron Banerjee
6,876 Points

far away python challenge

in the far away python challenge, it asked "Write a function called far_away that takes one argument, a timedelta. Add that timedelta to datetime.datetime.now() and return the resulting datetime object." So, my following code was

def far_away(**kwargs):
    return datetime.datetime.now() + datetime.timedelta(**kwargs)

I used this in the python shell and it worked properly but the challenge on the site said bummer try again. People instead put the paramater, "timedelta", and added it to datetime.datetime.now() (return datetime.datetime.now() + timedelta instead of return datetime.datetime.now() + datetime.timedelta(**kwargs)) which also worked. How come that approached worked but mine with **kwargs did not even though it was correct when tested in the shell.

1 Answer

Steven Parker
Steven Parker
229,967 Points

You're obviously testing for a behavior other than what the instructions ask for. The challenge function should accept a single argument with no keyword, but the one shown here takes a variable number of keyword/value pairs using the "splat" operator.

The instructions also say that the argument should be a timedelta, not something to be converted into one.