Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
courtney Hatcher4,364 Points
Dates and times in Python, challenge. Need some guidance with this task and also to help me understand what i'm missing.
All in all, this task has defeated me. My partner whom also writes in python could not even help me with this, which is why i'm coming here. So, I understand the concept of the datetime.timedelta() and all the others but i'm just not understanding how to execute what this task needs to move on. More specifically- "to get the number of seconds, returns the number of minutes, rounded, between them. The first will always be older and the second newer.". Id appreciate any help with this task.
Thank you, -Courtney
import datetime def minutes(datetime1, datetime2): seconds = datetime1.timedelta.total_seconds() return minutes - seconds
datetime1.timedelta.total_seconds(), try using
datetime.timedelta.total_seconds() needs a timedelta argument, which you can get by subtracting your first datetime parameter from your second datetime parameter. You would then have the difference between your datetime parameters in seconds, which you can convert into minutes by dividing by 60, since a minute has 60 seconds. Next, round the number of minutes and return that value. To round a number
some_number, you can do