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 trialRandolph Judy
Courses Plus Student 28,198 PointsDon't understand why I getting an error with timestamp_old function. Runs fine on my local machine.
I ran my code with testing locally and I get the following output: 2002-06-12 20:34:52.120399. I keep getting the following error on the Treehouse site: "Bummer! timestamp_oldest() takes 1 positional argument but 8 were given". I changed my test list order and the list was sorted correctly.
import datetime
def timestamp_oldest(time_floats):
time_floats.sort()
return datetime.datetime.fromtimestamp(time_floats[0])
times = [2883939292.5, 2393939292.11, 1023939292.1204, 1045678292.0114]
print(timestamp_oldest(times))
2 Answers
Vittorio Somaschini
33,371 PointsHey Randolph.
I notice a couple of things here and there that you may want to take care of.
First: You have to get rid of the last 2 lines of code (from times = till the end). This is because the input in the code challenges is provided and the compiler with check your code against the provided input, so you don't have to provide your own times. Also, we are not asked to print anything, our function will only need to return a datetime.
Talking about your function, I think it is a matter of input handling here. As specified by the instruction we do not know the number of timestamps that will come in. You might have a quick look at this link, it takes a couple of minutes: http://stackoverflow.com/questions/3394835/args-and-kwargs
This will help you get rid of that error message! Please note that we are not provided with a list here, but a tuple instead. So next step would be take the input tuple and obtain a list that you can then sort and take the right value from when returning the correct datetime object.
I hope I made it clear, please let me know if still struggling.
Vittorio
Randolph Judy
Courses Plus Student 28,198 PointsThanks Vittorio. I had never used *args before. That's why I was trying to use a list for an argument. I had no problem after your tip. As for the input and print codes. I was using those to test my code locally. I have a poor internet connection so I have trouble with using the Treehouse work spaces for coding.
Vittorio Somaschini
33,371 PointsVittorio Somaschini
33,371 PointsHello Randolph,
I have edited your post for readability, please have a quick look at this thread for future reference on how to post format code on the Treehouse forums: https://teamtreehouse.com/forum/posting-code-to-the-forum
Ty Vittotio