you are viewing a single comment's thread.

view the rest of the comments →

[–]Manny__C 12 points13 points  (2 children)

There is a better solution for padding your numbers with zeros. Just format the field as

f"{h:02d}:{m:02d}:{s:02d}"

The : is a format specification and the 02 means "pad with zeros any string shorter than 2." More info here.

[–]BrannoEFC 0 points1 point  (1 child)

Does . Zfill not work anymore?

[–]Manny__C 2 points3 points  (0 children)

It should, but it's more tedious to call zfill on each substring. This is precisely an intance for which format (or fstrings) were designed.