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.

Dante Vittorelli
2,301 PointsGetting an error stating that the correct answer is wrong.
For some reason I am getting the error " Bummer! to_string
returned the wrong string. Returned '24 September 2012'."
I don't understand why because the challenge is asking for exactly that date, yet it's not passing.
Would anyone know why this is happening?
import datetime
def to_string(x):
x = datetime.datetime.now()
x = x.replace(year = 2012, month = 9, day = 24)
z = x.strftime('%d %B %Y')
return z
[MOD: added ```python markdown formatting -cf]

Dante Vittorelli
2,301 PointsSorry, I clicked the checkbox that says "attach code to post" but I guess it didn't attach it.
import datetime
def to_string(x):
x = datetime.datetime.now()
x = x.replace(year = 2012, month = 9, day = 24)
z = x.strftime('%d %B %Y')
return z
2 Answers

Chris Freeman
Treehouse Moderator 68,082 PointsThe error is your are overwriting the argument x
with your own value.
import datetime
def to_string(x):
#x = datetime.datetime.now()
#x = x.replace(year = 2012, month = 9, day = 24)
z = x.strftime('%d %B %Y')
return z
This should work for Task 1

Dante Vittorelli
2,301 PointsOh wow... my answer makes no sense now that I get it haha. Thank you for your help.
Chris Freeman
Treehouse Moderator 68,082 PointsChris Freeman
Treehouse Moderator 68,082 Pointsplease post your code! Thx.