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

Holden Glass
Holden Glass
6,077 Points

what is the time_tango input format?

So have an idea on what is coming into the function but I want to make sure that I have the data right. It is a date and time object so the incoming date would be like datetime.date(2017, 3, 1), correct? And the time would be like date time.time(17, 1, 14, 197484) right? Some clarification would be nice. Thanks.

combo.py
import datetime

def time_tango(date, time):
    return datetime.datetime.strptime('{} {}'.format(date, time), '%m-%d-%y %H:%M')

1 Answer

Ryan S
Ryan S
27,276 Points

Hi Holden,

Here is a hint: you might want to review the datetime.combine() method.

Also, it is good to get in the habit of not naming your variables the same as python keywords or library objects. "date" and "time" already represent something in the datetime library. In this case it will pass, but it can lead to problems down the road as things get more complex.

Holden Glass
Holden Glass
6,077 Points

K. Thanks. I'm starting to do a little bit of JavaScript and he just talked about names you can't use for variables because they are key words in JS.