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

I need help with the timedelta minute challenge

I do not understand why this doesn't work. Can somebody please help me here. Thank you in advance.

minutes.py
import datetime

def minutes(datetime1, datetime2):
    difference_sec = datetime2.total_seconds() - datetime1.total_seconds()
    difference_min = difference_sec / 60
    return round.difference_min

1 Answer

Steven Parker
Steven Parker
231,269 Points

A "datetime" doesn't have a "total_seconds" method. But if you subtract one "datetime" from another, the result will be a "timedelta", and those do have such a method.

Also, "round" is a function; and when you call a function you write its name and then a pair of parentheses where you can place any arguments being passed to it.

Of course! Thank you. It all makes sense now :)