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 trialGuy-Francis Kono
9,289 PointsTime-Stuck...
Can someone please help me with this challenge? I can't seem to make head-ways with this no matter how I try it...
import datetime
time_record_1 = datetime.datetime.today() - datetime.timedelta(hours=2)
time_record_2 = datetime.datetime.today()
def minutes(time_record_1, time_record_2):
time_diff = time_record_2 - time_record_1
print(datetime.timedelta.total_seconds(time_diff))
1 Answer
Steven Parker
231,248 PointsIt looks like you have three issues:
- The challenge asked for the result in minutes, not seconds (you'll need to convert)
- The challenge also asked for the result to be rounded
- You need to return the result, not print it
Also, while it doesn't hurt anything, the two variables you defined above the function are not used (and not necessary).
Guy-Francis Kono
9,289 PointsGuy-Francis Kono
9,289 PointsHi Steven. Thank you for helping out.
I attempted to convert the seconds to minutes by dividing the hours by dividing the seconds by 60, rounding by using the .round() function, and replacing print() with return. However I do not get the right answer. Do you have any other tips to improve this?
Thank you