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

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

Yang Bi
Yang Bi
10,079 Points

Please help me with my code.

Got an "Bummer! Didn't get back a datetime" the code is meant to take no matter how many args and append them in a list then sort them and return the oldest time...

It would be easier if these exercises will let us know what exactly are the inputs to test our code..

timestamp.py
import datetime
# If you need help, look up datetime.datetime.fromtimestamp()
# Also, remember that you *will not* know how many timestamps
# are coming in.
def timestamp_oldest(*args, **kwargs):
    mylist = []
    for items in args:
        mylist.append(items)
    mylist.sort()
    return mylist[-1]

1 Answer

I just did this challenge. You need to return a datetime object, using the fromtimestamp method with the FIRST item in your list as the argument.

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