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!

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 Dates and Times Time Tango

Shawndee Boyd
Shawndee Boyd
5,917 Points

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

I am having a bit of trouble trying to get this. I would certainly appreciate any help. Here is my code

combo.py
import datetime


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

2 Answers

William Li
PLUS
William Li
Courses Plus Student 26,867 Points

Hi, Shawndee Boyd ,

Write a function named time_tango that takes a date and a time.

Since d, and t are already a date and a time.

  d = datetime.date()
  t = datetime.time()

You really DON'T need these 2 lines in your code, delete them and you're good to go.

Shawndee Boyd
Shawndee Boyd
5,917 Points

Thank you for the help, William. It worked!!! It is obvious that I over-thought this one, lol.