Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicates:
Intermediate display similar to PrintTemporary
Estimating progress on plots
How to create a progress bar?
How to determine how much of a table is generated?

I'm trying to print an output from every iteration of a Do[] loop, but without it continuing down the notebook. I want the Print[] output to be overwritten in the same cell with the new value. Here is a MWE of what I'm trying, but I can't seem to get the expected behavior.

    Print["Output = ", Dynamic[i]]

So in other words, on the first iteration, I want to see "Output = 1", and then every subsequent iteration I want to see the 1 change to a 2, 3, 4, etc. in the same cell.

share|improve this question

marked as duplicate by R. M., Sjoerd C. de Vries Sep 5 '12 at 22:09

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

One idea is to use PrintTemporary. – PlatoManiac Sep 5 '12 at 13:32
@PlatoManiac Post an answer! – Dr. belisarius Sep 5 '12 at 13:44
@Verde I am so so incorrigibly lazy! Thx for motivating... – PlatoManiac Sep 5 '12 at 13:49
Some more related near duplicates (if others want to choose alternatives):,, – R. M. Sep 5 '12 at 18:10

You could use Monitor like :

Monitor[Do[Pause[3], {i, 1, 10^3}], i]
share|improve this answer

There are many, many possibilities to achieve something like that. If you want to use Dynamic, you could set a global value which you observe


 If[OddQ[i], globalWatch = i];
 {i, 100}

I always suspect, whether Do is really needed, but sometimes when I for instance iterate over a list of files I want to process, I use it too. In such a situation, I use PrintTemporary as suggested by PlatoManiac to see the progress. PrintTemporary is nice because you can print all information you like and no matter it fills the screen, it gets erased after the computation is done.

share|improve this answer

Here is one way,

Print["Output = ", Dynamic[j]];
Do[j = i; Pause[0.1];, {i, 10}]
share|improve this answer

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