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 trialBerkley Frei
6,292 PointsI get the correct format requested by the challenge but it won't let me pass.
import datetime
def to_string(datetime): return datetime.strftime('%m %B %Y')
4 Answers
Berkley Frei
6,292 PointsLol, I hate it when this happens, but if you remove the period from "%d %B %Y" it will work. Pretty nit picky if you ask me :)
Maxim Andreev
24,529 Points%m %B %Y is wrong.
https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior
%m -> Month as 01-12 %B -> Month as localeβs full name. %Y -> Year as xxxx
you need %d not %m
it's ('%d %B %Y')
Kenneth Love
Treehouse Guest TeacherWe use Python 3 :)
Berkley Frei
6,292 PointsOops, duh, you are totally right. I feel a bit silly for posting this but thank you for the reply, sir!
zfusdjitsz
2,797 PointsMy error is saying: "Bummer! to_string
returned the wrong string. Returned '21 October 2015.'."
import datetime
def to_string(date_time):
return date_time.strftime("%d %B %Y.")
zfusdjitsz
2,797 Pointszfusdjitsz
2,797 Pointswow you were right. Would you look at that. That is rather nit picky
Kenneth Love
Treehouse Guest TeacherKenneth Love
Treehouse Guest TeacherI've updated the code challenge to be both more explicit in what it wants back and more forgiving in how it judges the response. Thanks for bringing it up.
Most of the time, my thought on this is that programming is "nitpicky" and we should learn to be as exact as possible while working. Sometimes, though, it's good to have a bit of wiggle room.