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

Alexander Kallaway (Emelianov)
Alexander Kallaway (Emelianov)
10,307 Points

Figuring the POSIX timestamp challenge out, getting NoneType error when trying to unpack a tuple of args into a list

I am getting a list of arguments with def my_func(*args):

I've tried:

def my_func(*args):
    posixes = []
    for i in args:
        posixes.append(i)

I've also tried:

def my_func(*args):
    posixes = list(args)

Please help! :)

Alexander Kallaway (Emelianov)
Alexander Kallaway (Emelianov)
10,307 Points

I am sorry for the poor markdown usage with code, but hopefully you get the gist of it.

Alexander Kallaway (Emelianov)
Alexander Kallaway (Emelianov)
10,307 Points

Here is the full code I currently have:

def timestamp_oldest(*args):
  posix_list = list(args)

  posix_list = posix_list.sort()

  oldest = posix_list[len(posix_list)-1]

  return datetime.datetime.fromtimestamp(oldest)

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

Alexander, You are so very close. Remember POSIX time is an value that gets larger as time passes. So the oldest date would have the lowest number. Therefore you want posix_list[0]:

  oldest = posix_list[0]

Here is my full solution for Task 1:

import datetime

def timestamp_oldest(*args):
    lst = list(args)
    lst.sort()
    return datetime.datetime.fromtimestamp(lst[0])