Converting minutes to HH:MM format in Python
python, time
Solution
Use the `divmod()` function:
'{:02d}:{:02d}'.format(*divmod(minutes, 60))
Here `divmod()` divides the minutes by 60, returning the number of hours and the remainder, in one.
Demo:
>>> minutes = 135
>>> '{:02d}:{:02d}'.format(*divmod(minutes, 60))
'02:15'
Problem
First of all, I'd like to point out that I'm a beginner with Python. My problem is that I can't figure out what is the proper way to convert minutes to HH:MM format in Python. Any help is appreciated!