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

Einars Vilnis
Einars Vilnis
8,050 Points

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
Einars Vilnis
Einars Vilnis
8,050 Points

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

3 Answers

Rob Bridges
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 Points

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.

Einars Vilnis
Einars Vilnis
8,050 Points

Yes it did help ! thanks for your time.

Einars Vilnis
Einars Vilnis
8,050 Points

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