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 Dating Methods

Ron Chan
Ron Chan
10,987 Points

Code Challenge: Time Tango

I am not passing the challenge for some reasons. In answering the question, I am making a lot of assumptions here about the format of date and time which will be passed into the time_tango method as arguments. Can I assume for the code challenge the date is in the year-month-date format while time is in the hour-minutes format?

import datetime

def time_tango(date, time):
  date_time = datetime.datetime.strptime("{} {}".format(date, time), "%Y-%m-%d %H:%M")
  return date_time

1 Answer

you need to use datetime combine, does that help? =D

Ron Chan
Ron Chan
10,987 Points

Yes it does, mike. Thanks for not giving away the plot. :o)