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 trialMichael Revy
3,882 Pointstimestamp.py 'float' object is noniterable - I run this on my machine and it seems to work
import time, datetime
def timestamp_oldest(*args): new_list = sorted(args[0], reverse=True) return datetime.datetime.fromtimestamp(new_list[0])
posix_list = [] for _ in range(10): posix_list.append(time.time()) print(timestamp_oldest(posix_list))
# If you need help, look up datetime.datetime.fromtimestamp()
# Also, remember that you *will not* know how many timestamps
# are coming in.
import time, datetime
def timestamp_oldest(*args):
new_list = sorted(args[0], reverse=True)
return datetime.datetime.fromtimestamp(new_list[0])
posix_list = []
for _ in range(10):
posix_list.append(time.time())
print(timestamp_oldest(posix_list))
Samuel Havard
6,650 PointsSamuel Havard
6,650 PointsBecause of the way Unix times are recorded, the older times are smaller numbers. You can search for the minimum number from your list of *args. I found the above code floating around here before and thought it was pretty clever.