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 trialLeon Fortgens
Courses Plus Student 3,788 PointsThe workspace seems bugged
The question: Create a function named to_string that takes a datetime and gives back a string in the format "24 September 2012".
My code: import datetime
def to_string(datetime): datetime = datetime.strftime('24 September 2012') return datetime
date_one = datetime.datetime.strptime("24 September, 2012", "%d %B, %Y") print(to_string(date_one))
The error message:
to_string
returned the wrong string. Returned '24 September 2012'.
This has been really damn frustrating since it says i returning the string in the question but its wrong
1 Answer
Steven Parker
231,261 PointsThe sample date (24 September 2012) is given as a format example only, the function must use the parameter instead of a literal. When the challenge checks your work, it will pass a different date in for the argument.