# Generate equal length strings from numbers by padding with "0"?

**URL:** https://discourse.julialang.org/t/generate-equal-length-strings-from-numbers-by-padding-with-0/41365
**Category:** General Usage
**Created:** [June 14, 2020, 11:21am UTC](https://discourse.julialang.org/t/generate-equal-length-strings-from-numbers-by-padding-with-0/41365 "2020-06-14T11:21:18Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [June 14, 2020, 11:29am UTC](https://discourse.julialang.org/t/generate-equal-length-strings-from-numbers-by-padding-with-0/41365/2 "2020-06-14T11:29:38Z")

</div>

```julia
julia> x = [1, 14, 356];

julia> function pad_zeros(x)
           strs = string.(x)
           m = maximum(length, strs)
           lpad.(x, m, "0")
       end
pad_zeros (generic function with 1 method)

julia> pad_zeros(x)
3-element Array{String,1}:
 "001"
 "014"
 "356"

```

---

_[View the full topic](https://discourse.julialang.org/t/generate-equal-length-strings-from-numbers-by-padding-with-0/41365)._
