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 trialanhedonicblonde
3,133 Pointsminutes.py - confused about how to go about this one
hi there, I'm having a little issue with datetime and timedelta... I'm not really sure how to go about this challenge. I gave it a shot as you can see but my answer is wrong wrong wrong. Can someone spell this out for me? thanks so much!! :) a
import datetime
def minutes(datetime1, datetime2):
minutes = datetime1 - datetime2
return round(minutes)
1 Answer
Steven Parker
231,269 PointsHere's a few hints:
- Remember the challenge said, "You'll need to subtract the first from the second."
- when you subtract datetimes, you get a timedelta
- timedeltas have a method you can call to get the duration in seconds
- you can calculate minutes when you have seconds
anhedonicblonde
3,133 Pointsanhedonicblonde
3,133 PointsThanks for the reply. I think I need to review the video again because I am still lost (except I saw where I was trying to do the subtraction backwards).
update: i get now thanks