# REPL and for loops (scope behavior change)

**URL:** <https://discourse.julialang.org/t/repl-and-for-loops-scope-behavior-change/13514>\
**Category:** General Usage\
**Created:** [August 15, 2018, 5:26pm UTC](https://discourse.julialang.org/t/repl-and-for-loops-scope-behavior-change/13514 "2018-08-15T17:26:35Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Anderson\_Goncalves\_E](https://avatars.discourse-cdn.com/v4/letter/a/a9adbd/32.png) [@Anderson\_Goncalves\_E](https://discourse.julialang.org/u/Anderson_Goncalves_E)\
**Post date:** [August 19, 2018, 7:34pm UTC](https://discourse.julialang.org/t/repl-and-for-loops-scope-behavior-change/13514/7 "2018-08-19T19:34:30Z")

</div>

Hi Guys, i’m having the same problem in Jupyter Notebook. I’m creating my own Julia tutorial following the youtube “Intro to Julia” video.

In a code cell I made it:

```julia
n=0
while n < 10
    println(n)
   n+=1
end

```

And the result was:

UndefVarError: n not defined

Stacktrace:  
[1] top-level scope at ./In[18]:3 [inlined]  
[2] top-level scope at ./none:0

I’ve tried to put the local status in any place but the result still goes wrong, the solution came following @saschatimme instructions (or at least how I interpreted that), like below:

```julia
n=0
while n < 10
    println(n)
   global n+=1
end

```

I’m newbie in programming.

This problem is a kind of bug?

Am I doing something wrong?

Thanks since now guys!

---

_[View the full topic](https://discourse.julialang.org/t/repl-and-for-loops-scope-behavior-change/13514)._
