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
Javi Caballero7,422 Points
Create a new function named from_string that takes two arguments: a date as a string and an strftime-compatible format s
Bummer: descriptor 'strftime' requires a 'datetime.date' object but received a 'str'
I'm not sure why it says that, could anyone tell me what I'm missing?
## Examples # to_string(datetime_object) => "24 September 2012" # from_string("09/24/12 18:30", "%m/%d/%y %H:%M") => datetime import datetime def to_string(datetime_birthday): #Not Kenneth's birthday date_plan = datetime_birthday.strftime('%d %B %Y') return date_plan def from_string(date_object, strf_time): date_object = datetime.datetime.strftime(date_object, '%d %B %Y') strf_time = date_object.strftime('%d %B %Y') return strf_time
Steven Parker228,001 Points
Here's a few hints:
- the first argument is named "date_object" — did you forget that both arguments are strings?
- "strf_time" is the second argument, you'll need to use it but not assign anything to it
- the "strftime" method returns a string, but this task needs to return a datetime
- perhaps the second task needs to use a different datetime method