Sunday, October 13, 2013

Convert seconds to minutes in Python


Let's say you have 255 seconds and you wish to have it as minutes and seconds,

mins, secs = divmod(255, 60)

Using divmod() will give you the minutes and seconds.
The same can be done for a minutes-to-hours conversion

No comments:

Post a Comment