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
Lyric Abbott
35,595 PointsHELP
Create a function named timestamp_oldest that takes any number of POSIX timestamp arguments. Return the oldest one as a datetime object.
iDK HOW TO START
2 Answers
Ratik Sharma
32,885 PointsHere's a general idea of what you should try to do:
- Since POSIX timestamps are floats, they can be compared using the comparison operators (less than, greater than etc.)
- The trick to the problem is variable unpacking. Look the term up or re-watch some videos from the old Python courses to help you out
- As for getting the smallest timestamp, I'd suggest picking one of the passed arguments as the smallest and then comparing each of the other arguments with it and ONLY updating it when something smaller comes up. By the process of elimination, you'll be left with the smallest timestamp
- And finally, use datetime.datetime.fromtimestamp() to get the datetime object
And if you want want some more help, refer to this Gist: https://gist.github.com/Ratik96/170e5d74117e5ab206c3
Ratik Sharma
32,885 PointsKenneth Love, absolutely. Sorry for doing that. I've updated my answer.
Kenneth Love
Treehouse Guest TeacherKenneth Love
Treehouse Guest TeacherThanks for answering. In the future, though, can you not jump straight to giving away an answer? I'd rather people work through to the solution themselves instead of being handed it.