Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Dates and Times in Python Let's Build a Timed Quiz App Timestamp Ordering

can't solve this(

Could anybody help with the task?

# 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):
    oldest = timestamp_oldest[0]
    for var in *args:
        if var < oldest:
            oldest = var
    return oldest

2 Answers

8,311 Points

The challenge can be solved in 4 steps.

Step1: Create a function that accepts any number of arguments.

def timestamp_oldest(*args):

Step2: Since we do not know how many arguments will be given, we'll create a list and append all the arguments into that.

timestamps = []
for value in args:

Step3: We need to sort the list to get the smallest number because the smallest number is the closest to the EPOC time.


Step4: Let's now convert the POSIX timestamp to a Datetime timestamp by using fromtimestamp() method.

return datetime.datetime.fromtimestamp(timestamps[0])

If you need more clarification let me know.

I've got it, thank you so much