Strings In Depth13 / 19
Up next

Zero-pad numbers

print("42".zfill(5))    # 00042
print(f"{42:05d}")      # 00042
print(f"{-7:+04d}")     # -007
What you're solving

zfill and format specifiers