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 trialjohn larson
16,594 Pointsthis works local without the * for unpacking but does not pass the challenge, wondering why?
import datetime
def timestamp_oldest(*ts_args):
# Create a function named timestamp_oldest that
# takes any number of POSIX timestamp arguments.
# Return the oldest one as a datetime object.
# Remember, POSIX timestamps are floats and
# lists have a .sort() method.
ts_list = []
for ts in ts_args:
ts_list.append(ts)
order = sorted(ts_list)
return datetime.datetime.utcfromtimestamp(order[0])
2 Answers
Kenneth Love
Treehouse Guest TeacherIt works without the *
locally because you're turning ts_args
into a list and then sorting it. You can do this whole thing without converting ts_args
to a list, which'll save processing time and memory.
How would you do that?
FHATUWANI Dondry MUVHANGO
17,796 Pointsthanks for asking this question John, i was breaking my brain with one
john larson
16,594 Pointsjohn larson
16,594 PointsThanks Kenneth, didn't expect a response from you. Love your course :D I will look at how to do that without converting ts_args to list.