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

Roger Finlayson
Roger Finlayson
3,236 Points

minutes.py got the wrong number of minutes

I do not understand why this keeps giving me the wrong answer. I wrote it in a file in workspaces and it was fine.

minutes.py
import datetime

def minutes(dt1, dt2):
    diff = dt2 - dt1
    return round(diff.total_seconds()/60)
Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

Sorry. You will need to come back to this challenge once the checker bug is fixed.

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

Your code is correct and should pass the challenge. There appears to be a bug in the checker. The challenges was recently changed to distinguish between using the attribute seconds and the method total_seconds().

Flagging Kenneth Love to check the validation on the Timedelta Minute challenge.

The posted code:

import datetime

def minutes(dt1, dt2):
    diff = dt2 - dt1
    return round(diff.total_seconds()/60)

Got the response:

:x: Bummer! Got the wrong number of minutes. Expected 67, got 1507.

It seems the challenge has the old expected value from before the test data was changed to be greater than a day.

Gianmarco Mazzoran
Gianmarco Mazzoran
22,076 Points

.append() myself to this post, just in case the notification of the debug is posted here!

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Updated the prompt and the checker. Your original code should pass now.