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 trial

Python Dates and Times in Python (2014) Dates and Times Time Tango

what am i doing wrong? Ive run this on another text editor and get a correct answer.

I keep on getting the try again error with no clarification as to what is wrong with my code. I've run this outside of team treehouse and looks like I'm getting the correct answer. If anybody could tell me what I'm doing wrong id appreciate it.

combo.py
import datetime
def time_tango(date, time):
    full = f"{date} {time}"
    full_parse = datetime.datetime.strptime(full, '%m/%d/%y %H:%M')
    full_date = full_parse.strftime('%m/%d/%y %H:%M')
    return full_date

1 Answer

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,722 Points

You're far too clever for this challenge! Your solution would work for a very specific datetime format, but...

It is much simpler. Hint: there is a method of datetime.datetime.combine(date, time) that will handle it for you!

Simply make that the return value of time_tango() and you'll be golden!