Variable scope in while loops

You need a global a in the while loop.

See also https://github.com/JuliaLang/julia/issues/28789 and Global variables not visible within loops in scripts … this behavior is slated to be changed in interactive contexts. In IJulia/Jupyter it is already changed.