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

Can anybody please post up the code to this challenge? This is what I have. I can't find the problem to this code.

Help please.

combo.py
import datetime

def time_tango(date, time):
  combined = datetime.combine(datetime.date(date), datetime.time(time))
  return combined

3 Answers

import datetime

def time_tango(date, time): combined = datetime.datetime.combine(datetime.date(date), datetime.time(time)) return combined

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Kevin;

The datetime module in Python also has a datetime class that needs to be used. Then, inside the combine() method you need to pass in the arguments given to time_tango.

You can also simplify your code a little bit and simply return the value directly without assigning it to a variable. In other words you could do:

return answer

instead of

combined = answer
return answer

Post back if if you are still stuck.

Ken

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Your date and time arguments will already be datetime.date and datetime.time objects, so you don't have to cast them.