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 trialEinars Vilnis
8,050 Pointswhat am I doing wrong?
combo.py challenge i feel like i am doing everithing right but ir some how isnt working. where is my problem?? can somebody help me please? thanks
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, 1)
time = time.strftime('%H:%M')
datetime1 = '{} {}'.format(date, time)
new_date = datetime.datetime.strptime(datetime1, '%d.%m.%Y %H:%M')
return new_date
2 Answers
James Simshaw
28,738 PointsHello,
There is a function in datetime that can take a date and a time and give you a datetime object. You can find out more about datetime objects at https://docs.python.org/3/library/datetime.html#datetime-objects
michaelangelo owildeberry
18,173 Pointswhat happens when you try return time_tango? =)
Einars Vilnis
8,050 Points'''def time_tango(date, time): date = datetime.date(2015, 10, 15) time = datetime.time(10, 10, 10, 10, None) datetime1 = datetime.datetime.combine(date, time) return datetime1'''
Einars Vilnis
8,050 PointsEinars Vilnis
8,050 Pointsthank you. i did find combine but it still shows that i return the wrong datetime
James Simshaw
28,738 PointsJames Simshaw
28,738 PointsCould you provide your updated code so that we can troubleshoot it more? All you should need to do is return the combined datetime object.
Einars Vilnis
8,050 PointsEinars Vilnis
8,050 Points'''def time_tango(date, time):''' ''' date = datetime.date(2015, 10, 15)''' '''time = datetime.time(10, 10, 10, 10, None)''' '''datetime1 = datetime.datetime.combine(date, time)''' '''return datetime1'''
James Simshaw
28,738 PointsJames Simshaw
28,738 PointsHello,
In your updated code, it looks like you're doing a lot of unnecessary stuff. You don't need to assign anything to date or time, those values will be passed into the function when it is called. You only need the lines that are creating datetime1 and returning it.
Einars Vilnis
8,050 PointsEinars Vilnis
8,050 Pointsthank you mate
James Simshaw
28,738 PointsJames Simshaw
28,738 PointsYou're welcome. Have fun with Python.