1
$\begingroup$

I have a

list1 = {1, 23, 4, 14} (*max entry is 99*)

and want to create from that another

list2 = {01, 23, 04, 14}

preceding zeros if the number is less than 10.

How can I do that?

$\endgroup$
  • $\begingroup$ NumberForm should work... $\endgroup$ – Yves Klett Dec 20 '18 at 13:55
  • $\begingroup$ @Yves Klett: can you please show the solution with NumberForm $\endgroup$ – lio Dec 20 '18 at 14:16
2
$\begingroup$
IntegerString[list1, 10, 2]

Note that the resulting list consists of strings and not numbers. But maybe that is sufficient for your application?

$\endgroup$
  • $\begingroup$ Thank you. Yes, from the numbers I produce strings for labels. $\endgroup$ – lio Dec 20 '18 at 14:00
  • $\begingroup$ Okay, then it's the way to go! =) You're welcome. $\endgroup$ – Henrik Schumacher Dec 20 '18 at 14:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.