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
Scott Davis
1,925 Pointstime_tango adding datetime.datetime objects
For the time_tango challenge, it seems we are creating two strings and combining as datetime.datetime objects. Here's my code:
I used the strptime() method for creating a datetime from a string. I tried combining the datetime objects with the combine() function, but got an error.
import datetime
def time_tango(date, time):
date = datetime.datetime.strftime('2015-05-1', '%m/%d/%y')
time = datetime.datetime.strftime('08:00:00', '%H:%M:%S')
return datetime.datetime.combine(date, time)
This is my first time making a post, so I don't know why the different colors aren't showing. I followed the guide for posting on treehouse, but the it looks like I put a # on every line.
1 Answer
Chris Freeman
Treehouse Moderator 68,468 PointsIt looks like you're not using the input parameters date and time, but are redefining them within the function. Let the input parameters flow directly to your return statement:
import datetime
def time_tango(date, time):
#date = datetime.datetime.strftime('2015-05-1', '%m/%d/%y')
#time = datetime.datetime.strftime('08:00:00', '%H:%M:%S')
return datetime.datetime.combine(date, time)
Scott Davis
1,925 PointsThat worked Chris, thanks. I accidentally added an extra step about creating an object and combining them. Looks like I needed to combine the parameters.
Chris Freeman
Treehouse Moderator 68,468 PointsChris Freeman
Treehouse Moderator 68,468 PointsFormatting help: use triple-backtick-python to open the code block. Close with triple-backtick.