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
  David Jones
2,977 PointsI've attempted writing this function 2 different ways and both ways fail in the challenge task, but pass in PyCharm
Both of these functions work in PyCharm but fail in the challenge on Treehouse
from datetime import datetime
def time_tango(date1, time1):
    dt = datetime.strptime(f'{date1} {time1}', '%Y-%m-%d %H:%M:%S')
    return dt
from datetime import datetime, date, time
def time_tango(date1, time1):
    year = date1.year
    month = date1.month
    day = date1.day
    hour = time1.hour
    minute = time1.minute
    seconds = time1.second
    dt = datetime(year, month, day, hour, minute, seconds)
    return dt
from datetime import datetime
def time_tango(date1, time1):
    dt = datetime.strptime(f'{date1} {time1}', '%Y-%m-%d %H:%M:%S')
    return dt
2 Answers
Chris Freeman
Treehouse Moderator 68,468 PointsHey David Jones, The short answer is you are be correct! The issue is with the challenge checker.
For your case, import just the top level module datetime then use datetime.datetime
Also fixed to include microsecond 
This fails:
#import datetime
from datetime import datetime
def time_tango(date1, time1):
    year = date1.year
    month = date1.month
    day = date1.day
    hour = time1.hour
    minute = time1.minute
    seconds = time1.second
    microsecs = time1.microsecond  # ADD
    # calling class directly 
    dt = datetime(
        year, month, day, hour, 
        minute, seconds, microsecs)
    return dt
This passes 👍
import datetime
# from datetime import datetime, date, time
def time_tango(date1, time1):
    year = date1.year
    month = date1.month
    day = date1.day
    hour = time1.hour
    minute = time1.minute
    seconds = time1.second
    microsecs = time1.microsecond  # ADD
    # calling through module namespace 
    dt = datetime.datetime(
        year, month, day, hour, 
        minute, seconds, microsecs)
    return dt
Marking as feedback to devs.
Post back if you need more help. Good luck!!!
David Jones
2,977 PointsI realized I was leaving out the purpose of this assignment which was to use combine()
Chris Freeman
Treehouse Moderator 68,468 PointsPerhaps so, but the combine method is not “required” to pass.
Chris Freeman
Treehouse Moderator 68,468 Points...and you may have uncovered a bug in the challenge checker! So +1 👍