Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Dates and Times in Python 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