# How do I repeat the number of times a nested for loop does an iteration?

I am trying to write a nested for loop that prints the pairs 00 through 55, with each digit running from 0 to 5.

In other words, I want the output to appear as so: 00, 01, 02, 03, 04, 05, 10, 11, ..., 50, 51, 52, 53, 54, 55.

I know I can do this using two variables, one representing the first digit and the other representing the second digit. I'm also aware of how to create a for loop that prints, for example, the digits 0-5 one time, but how do I get Mathematica to repeat this process 5 times so that the pattern of output continues up until 55?

• Using Print in loops is the best way to freeze the front end. When you can, try to use Monitor. Feb 26 '19 at 7:16

From my experience in Wolfram language, not only are explicit loops discouraged, but also explicit Printing is, if one uses the notebook interface. One usually collects data in a List ({...}) construct:

StringJoin @@@ Tuples[CharacterRange["0", "5"], 2]


It is not a good idea to use For loops, if you must use explicit loops, you can use Do or Table

Do[
Do[
myVar = ToString[i] <> ToString[j];
Print[myVar]
, {j, 0, 5}
],
{i, 0, 5}
]


You can also count in 6 digits

data = PadLeft[Table[IntegerDigits[i, 6], {i, 35}]]; Do[Print@StringJoin[ToString[#] & /@ i], {i, data}]