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 trialAmber Cyr
19,699 PointsBummer! Didn't get back the correct datetime
This code seems to work perfectly when I run it in my own code editor and console, but I keep getting a bummer message when I submit it. What am I doing wrong?
# If you need help, look up datetime.datetime.fromtimestamp()
# Also, remember that you *will not* know how many timestamps
# are coming in.
import datetime
def timestamp_oldest(*args):
time = []
for item in args:
time.append(datetime.datetime.fromtimestamp(item))
return max(time)
1 Answer
Jeff Wilton
16,646 PointsI like your idea of using the max function instead of the sort() function that they recommended for some reason. The only problem is that timestamps get larger as time goes on, and in this example they want the oldest time, not the newest one, so you just have to use min(time) instead of max. :)
Amber Cyr
19,699 PointsAmber Cyr
19,699 Pointsah thank you Jeff! for some reason my brain was like "its the largest one!". I swear I can read... :]