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

Devin Scheu
Devin Scheu
66,191 Points

Date Time Python

Write a function named time_tango that takes a date and a time. It should combine them into a datetime and return it.

Ive been having a very hard time with this.

Hi Devin,

could you tell us what you have done so far?

4 Answers

You almost have it.

The problem is that you try to call a function named combine inside the datetime module. But there is no combine function inside that module but a combine method (methods are called on instances/objects and functions don't).

What you should try to do is call a method named combine, which is inside a class named datetime. And the class datetime is inside a module which is also named datetime.

To not trying to confuse you too much, you only forgot one word in the return line. Do you see it?

Let me know if you need some more help but I think you will get it :D

Jose Luis Lopez
Jose Luis Lopez
19,179 Points

import datetime

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

This is what it worked for me

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Check the docs for the combine() method.

Devin Scheu
Devin Scheu
66,191 Points
import datetime

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

What am I doing wrong, sometimes I confuse syntax's between language.