Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


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
220,925 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.