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 trialPitrov Secondary
5,121 PointsHow do I round time minutes?
It says I have to round the minutes. I do not know how to, please help me!
Thanks!
import datetime
def minutes(time1, time2):
if time1.timedelta.total_seconds() > time2.timedelta.total_seconds():
1 Answer
Oskar Lundberg
9,534 PointsHey there! Here is my solution to the challenge, hope it helps :D
import datetime
def minutes(time1, time2):
difference = time2 - time1 # Creates a timedelta
diff_seconds = difference.total_seconds() # calls the total_second() function on the timedelta to get the total seconds.
diff_minutes = diff_seconds / 60 # divides the seconds by 60, to get the total minutes.
return round(diff_minutes) # rounds the minutes to get a whole number. (and returns it)
Pitrov Secondary
5,121 PointsPitrov Secondary
5,121 PointsThanks!
Erik Burmeister
Python Web Development Techdegree Graduate 17,108 PointsErik Burmeister
Python Web Development Techdegree Graduate 17,108 PointsOskar Lundberg, Thanks for your response to the post. The description on each step helped a ton!