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.
Pitrov Secondary5,121 Points
How do I round time minutes?
It says I have to round the minutes. I do not know how to, please help me!
import datetime def minutes(time1, time2): if time1.timedelta.total_seconds() > time2.timedelta.total_seconds():
Oskar Lundberg9,510 Points
Hey 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)