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 trialThan Win Hline
1,679 Pointstimedelta minuite
What I'm doing wrong here? can anyone please tell me what this 'round' does ??
import datetime
def minutes(datetime1,datetime2):
datetime1 = datetime.timedelta.total_seconds(datetime1)
datetime2 = datetime.timedelta.total_seconds(datetime2)
diff_in_min = (datetime1 - datetime2)/60
return round(diff_in_min)
2 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsYou are on the right track, here are some hints:
- be mindful when subtracting.
datetime2
is the βlaterβ time and therefore has the larger epoch time -
the
total_seconds
method is only available on thetimedelta
object:(datetime2 - datetime1)
- π
(datetime2 - datetime1).total_seconds()
is legal syntax but you may wish to assign the subtraction to a variable, then call the method on that variable.
- π
the first and second statements reassigning datetime1 and datetime2 are not necessary. (I commented them out
Post back if you need more help. Good luck!!!
Than Win Hline
1,679 PointsThank you for the response. It helped me to solve the problem.