Hi, I’m doing the Introduction to Julia course (https://juliaacademy.com/courses/375479/lectures/5816184) and this happens when i run the code for a while loop.
¿Could someone explain this to me and tell me the correct way to do it?
jling
2
the warning message before the error literally tells you what’s going on, please read it.
In this case, you want to take the global i
advise probably
1 Like
oheil
3
Welcome @nicoo-c
You find all you need about this here: Scope of Variables · The Julia Language
3 Likes
Thanks, I understand now.
Solved with:
i = 0
while i < 10
global i += 1
println(i)
end
2 Likes