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

combo.py callenge

hallo guys! I simply don't get this at all . i guess that my function is wrong but I don't even now where and why :(

combo.py
import datetime

def time_tango(day, mytime):
  day = datetime.datetime.strftime('%d/%m/%y')
  mytime = datetime.datetime.strftime('%H:%M')
  daymytime1 = day + mytime
  daymytime = datetime.datetime.strptime(daymytime, '%d/%m/%y %H:%M')
  return daymytime

import datetime

def time_tango(date, time): date = datetime.date(2015, 10, 15) date = date.strftime('%d.%m.%Y') time = datetime.time(10, 10, 10, 10, None) time = time.strftime('%H:%M') datetime1 = '{} {}'.format(date, time) new_date = datetime.datetime.strptime(datetime1, '%d.%m.%Y %H:%M') return new_date

my new try and still isnt working

Hey there, is it giving an error code or compiler error?

3 Answers

Hey there Einars,

I can see that you were able to look into this and found the function on the new thread, was that able to clear up any questions you had?

If so, I was able to get the challenge to pass by passing the function built into it

import datetime

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

Thanks, let me know if this doesn't help.

Yes it did help ! thanks for your time.

it shows that it doesn't return the right datetime, and by the way ' time = datetime.time(10, 10, 10, 10, None)' in my final code

Okay I'm on my phone right now I'd have to give this a look in an hour or so once I get home.

thank you.