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 trialHolden Glass
6,077 PointsDon't know how to get enough place holders in timestamp_oldest
I get the question but the only part I don't get is how to be able to get all the timestamps into the function. Advise would be much appreciated.
# 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(time_stamps):
time_stamps.sort()
return incoming[:len(incoming)-2:-1]
3 Answers
Christopher Shaw
Python Web Development Techdegree Graduate 58,248 PointsThere are a few things you need to look at.
You are taking mutiple timestamps, you dont know how many, so you need the *args
def timestamp_oldest(*args):
You need to create a list of time stamps
time_stamps=[]
for ea in args:
time_stamps.append(ea)
You need to sort the list, the oldest will be first. So return the first record.
time_stamps.sort(reverse=True)
return datetime.datetime.fromtimestamp(time_stamps[1])
james south
Front End Web Development Techdegree Graduate 33,271 Pointsit tells you lists have a sort method, so it's going to call your function with a list of timestamps as the argument. your function needs to sort these and return the oldest one. they are floats so sorting from lowest to highest would put the oldest (lowest) one at index 0 in the list, then just return that as a datetime object as requested.
Holden Glass
6,077 PointsI tried just putting in a single argument and it said that the function took one argument and it was given eight.
james south
Front End Web Development Techdegree Graduate 33,271 PointsHolden Glass i just saw your comment. if you are still on this one post a new question with your code so we can see where you are.
Christopher Shaw
Python Web Development Techdegree Graduate 58,248 PointsChristopher Shaw
Python Web Development Techdegree Graduate 58,248 PointsSorry, I realize now I have answered more than you asked.
Holden Glass
6,077 PointsHolden Glass
6,077 PointsWhat's the difference between *args and *kwargs?