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

Kade Carlson
Kade Carlson
5,928 Points

Not sure what this question is trying to ask

The wording of this task is kind of confusing to me

minutes.py
import datetime

def minutes(datetime1, datetime2):
    now = datetime2 - datetime1
    return round(now.timedelta.total_seconds())

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

You are actually very close. When subtracting to date the time objects the result is a timedelta object. So, now is a time delta object that has the method total_sec(). Divide this value by 60 and you will get the seconds you seek.

  • change now.timedelta.total_sec to now.total_sec
  • divide this by 60 before you round

Post back if you have anymore questions. Good luck!!!

Kade Carlson
Kade Carlson
5,928 Points

It worked thank you so much!