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) Dates and Times Timedelta Minute

Aleksandar Stankovic
seal-mask
.a{fill-rule:evenodd;}techdegree
Aleksandar Stankovic
Python Development Techdegree Student 9,648 Points

What am I missing out here?

Hello guys, I tried my code in my own editor, and it works just fine, but here I get the answer to "try again". Is there something that I am missing?

Thanks for the response!

minutes.py
def minutes(datetime1,datetime2):
    return round(datetime.timedelta(seconds=datetime2-datetime1).total_seconds()/60)

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Aleksandar Stankovic

You seem to be on the right track, with just a couple corrections needed.

First, you can't declare a variable within the parameters of a method call, nor do you need to, so that part will need to be deleted. (seconds=datetime2-datetime1) should only be (datetime2-datetime1).
Second, datetime.timedelta doesn't actually take any parameters, but instead, should have the .total_seconds() method called on it directly, and those parameters should be inside of the .total_seconds() method call.

So, with the exceptions of the "seconds" variable that can't be there, you have everything there. With the above hints, I believe you should be able to refactor the code to pass.

Keep Coding! :) :dizzy: