Pluto: printing multiple statements in a for loop

Hi,

I have a simple for loop that involves printing multiple statements. This material is for teaching, so I want to keep it intuitive and straightforward. The code below works in VSCode and Jupyter, but I do not know how to make it work in Pluto. I looked carefully at issue #245, but have not found a helpful way to overcome my problem. Some help would be very much appreciated.

MWE:

a =  0.75
b = -2.0
c =  1.0
tol = 1e-12
maxiter = 500
Fₙ  = 0.0

for i = 1 : maxiter
    # Updating rule
    Fₙnew =  -(1/(b + Fₙ * c)) * a
    # Stopping rule:
    if abs(a + b * Fₙnew + c * Fₙnew^2) < tol
        println("convergence after $i iterations")
        println("final value for F is $Fₙ")
        break
    end
    Fₙ = copy(Fₙnew)
    if i == maxiter
        println("No convergence after $i iterations")
    end
end

Check the console. Pluto by default does not show print, you must use with_terminal() for package PlutoUI. Docstrings · PlutoUI.jl}

1 Like

@dmolina, thanks. I was doing a stupid mistake with the with_terminal() do option: I was keeping the Print function from Pluto in the loop, instead of using the native Julia println.

However, Pluto does accept by default the println stuff by using Print. In the example below, it prints the output; the annoying part is that it only prints the last one. If we have code that we used to run in VScode or Jupyter, it takes a certain amount of time to avoid stupid mistakes in the migration process.

a