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!

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

Enes artun
Enes artun
2,364 Points

Stuck on this challenge.

I've looked up another guide for this challenge after getting stuck on it. I have copied exact lines but it still won't work. What am I missing?

It gives Try again error.

minutes.py
import datetime

def minutes(day1, day2):
    timedelta = day2 - day1
    new_object = timedelta.total_seconds()
    new_object_in_minutes = timedelta/60

    return round(new_object_in_minutes)

1 Answer

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,372 Points

You were pretty close. You got a little confused with the logic of creating the object, but you were on the right track.

import datetime

def minutes(day1, day2):
    timedelta = day2 - day1
    return round( timedelta.total_seconds() / 60 )