In php, when I want to generate a array
formatted, I use the array_map
function.
So:
$numeros = range(1, 10);
array_map(function ($value) {
return sprintf('%04', $value);
}, $numeros);
Return:
array('0001', '0002', '0003', '0004' ...);
In python
, for this list
range(1, 10)
how could I do this same operation?
Is there any short and simple way to do this (same as or better than in PHP)?