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 trialAndrei Oprescu
9,547 PointsHow can I complete this challenge?
Hi! I have come across this question on a challenge that looks like this:
Write a function named time_tango that takes a date and a time. It should combine them into a datetime and return it.
I have created a code that looks like the one at the bottom of the page.
Can you please tell me what I have done wrong and how I can fix it?
Thanks!
Andrei
import datetime
def time_tango(date, time):
datetime1 = date.combine(time)
return datetime.datetime.strptime('%m/%d %H:%M', datetime1)
1 Answer
Steven Parker
231,236 PointsWhen the instructions say, "It should combine them into a datetime and return it" they mean to return the datetime itself. No need to convert it into a string.
But also you're not calling the "combine" function correctly. Take a look at the documentation page for the correct syntax.
Andrei Oprescu
9,547 PointsAndrei Oprescu
9,547 PointsThanks! I read the question wrong ;).
Andrei