Skip to main content
added 344 characters in body
Source Link
george2079
  • 39.1k
  • 1
  • 44
  • 111

Supposing you want to print from inside the loop (not waiting for the loop to finish) you can use Grid on each line with specified field widths:

 Do[
      Print@Grid[{{
        RandomChoice[DictionaryLookup["*"]], "=", 
        RandomReal[{1, 10}]^RandomInteger[12]}},
          ItemSize -> {{10, Full, 8}},
          Alignment -> {{Right, Center, Right}}],
    {10}]

enter image description here

Another approach for nicely formatted monitoring..

out = {};
Monitor[
     Do[  Pause[1]; 
          AppendTo[out, {RandomChoice[DictionaryLookup["*"]], "=", 
                         RandomReal[{1, 10}]^RandomInteger[12]}],
       {10}], 
                Grid[out, Alignment -> {Right, Center, Right}]]

Supposing you want to print from inside the loop (not waiting for the loop to finish) you can use Grid on each line with specified field widths:

 Do[
      Print@Grid[{{
        RandomChoice[DictionaryLookup["*"]], "=", 
        RandomReal[{1, 10}]^RandomInteger[12]}},
          ItemSize -> {{10, Full, 8}},
          Alignment -> {{Right, Center, Right}}],
    {10}]

enter image description here

Supposing you want to print from inside the loop (not waiting for the loop to finish) you can use Grid on each line with specified field widths:

 Do[
      Print@Grid[{{
        RandomChoice[DictionaryLookup["*"]], "=", 
        RandomReal[{1, 10}]^RandomInteger[12]}},
          ItemSize -> {{10, Full, 8}},
          Alignment -> {{Right, Center, Right}}],
    {10}]

enter image description here

Another approach for nicely formatted monitoring..

out = {};
Monitor[
     Do[  Pause[1]; 
          AppendTo[out, {RandomChoice[DictionaryLookup["*"]], "=", 
                         RandomReal[{1, 10}]^RandomInteger[12]}],
       {10}], 
                Grid[out, Alignment -> {Right, Center, Right}]]
Source Link
george2079
  • 39.1k
  • 1
  • 44
  • 111

Supposing you want to print from inside the loop (not waiting for the loop to finish) you can use Grid on each line with specified field widths:

 Do[
      Print@Grid[{{
        RandomChoice[DictionaryLookup["*"]], "=", 
        RandomReal[{1, 10}]^RandomInteger[12]}},
          ItemSize -> {{10, Full, 8}},
          Alignment -> {{Right, Center, Right}}],
    {10}]

enter image description here