Using Swift 5’s fancy new extendible interpolation:
extension DefaultStringInterpolation { mutating func appendInterpolation(pad value: Int, toWidth width: Int, using paddingCharacter: Character = "0") { appendInterpolation(String(format: "%\(paddingCharacter)\(width)d", value)) } } let pieCount = 3 print("I ate \(pad: pieCount, toWidth: 3, using: "0") pies") // => `I ate 003 pies` print("I ate \(pad: 1205, toWidth: 3, using: "0") pies") // => `I ate 1205 pies`