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

please can someone give me a hint?

not sure why it is a None type?

timestamp.py
# 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(*ts):
    ls = []
    for t in ts:
        ls.append(t)

    ls = ls.sort()

    ans = ls[-1]
    answer = datetime.datetime.fromtimestamp(ans)

    print(answer)

1 Answer

Steven Parker
Steven Parker
231,269 Points

The "NoneType" is the special type of "None", which is the absence of a value. This is happening because the .sort() method sorts the list in place, but doesn't return anything. So when you call it, you don't want to also use it as the value side of an assignment. Or if you wanted to do it another way, there's a function named sorted that returns a new list instead of changing the original.

Some other issues you might need to address:

  • the instructions ask you to return the result (not print it)
  • you want the oldest value, so you might need to rethink how sorting will order the list