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!
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 trial
Kenneth Bagwell Jr3,698 Points
not understanding why I'm not getting a string back
why aren't I getting a string back?
import datetime def to_string(datetime): datetime.strftime('%d %B %Y') return datetime # from_string("09/24/12 18:30", "%m/%d/%y %H:%M") => datetime
Asher OrrPython Development Techdegree Graduate 9,395 Points
Hi Kenneth! Here's the issue:
import datetime def to_string(datetime): datetime.strftime('%d %B %Y') #the line above needs to be stored in a variable. return datetime #you need to return the variable. #the variable stores the operation that converts your parameter, a datetime object, into a string.
Your code is returning the parameter datetime. When you click "Check Work," the Treehouse checker is passing in a datetime object as the parameter- not a string.
Your code should convert the parameter to a string, then return the string.
I hope this helps. Let me know if you have questions!