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 trialEhor Stashchyshyn
5,201 Pointswhats wrong with this code?
help plz cant understand whole day
import datetime
def far_away(timedelta):
return datetime.datetime.now() - datetime.timedelta(timedelta)
2 Answers
Andy Hughes
8,479 PointsAdding to Steven Parker's comment, you also don't need;
datetime.timedelta(timedelta)
You just need the name of the argument being passed into the function;
+ timedelta
That's good enough to pass the challenge. :)
Steven Parker
231,236 PointsThat's what I meant by "... since the argument is already a timedelta, it doesn't need to be processed by the method (just add it as it is)."
Andy Hughes
8,479 PointsSteven Parker - Haha, oh yes, I've just reread your comment. Apologies my friend :).
I retract my answer......Steven Parker's is correct! :P
Steven Parker
231,236 PointsThe instructions are pretty explicit, they say: "Add that timedelta to datetime.datetime.now() ..."
But this code is subtracting instead of adding. And since the argument is already a timedelta, it doesn't need to be processed by the method (just add it as it is).
Ehor Stashchyshyn
5,201 PointsEhor Stashchyshyn
5,201 Pointsimport datetime def far_away(timedelta): return datetime.datetime.now() + datetime.timedelta(timedelta)
its not working same as code above