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.

Python Dates and Times in Python Dates and Times Time Tango

jacob allen
seal-mask
.a{fill-rule:evenodd;}techdegree
jacob allen
Python Development Techdegree Student 4,324 Points

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 27,586 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!