Skip to content

Names and values · routine

Seconds to a clock

Write clock(seconds) returning a string "H:MM:SS" — minutes and seconds always two digits. clock(3725) is "1:02:05".

f"{m:02d}" pads a whole number with zeros to two digits.

Run adds print(clock(3725)) after your code, to try it.

Stuck on the idea rather than the code? The Types, and printing them nicely lesson walks through it.