# Error: LoadError: UndefVarError: user\_input not defined

**URL:** <https://discourse.julialang.org/t/error-loaderror-undefvarerror-user-input-not-defined/73783>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [December 29, 2021, 7:48pm UTC](https://discourse.julialang.org/t/error-loaderror-undefvarerror-user-input-not-defined/73783 "2021-12-29T19:48:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stanfordblaze](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stanfordblaze/32/32287_2.png) [@stanfordblaze](https://discourse.julialang.org/u/stanfordblaze)\
**Post date:** [December 29, 2021, 7:48pm UTC](https://discourse.julialang.org/t/error-loaderror-undefvarerror-user-input-not-defined/73783/1 "2021-12-29T19:48:28Z")

</div>

I’m new in Julia, honestly starting few moments ago seeing a tweet! I’m facing an unexpected error. It looks everything fine my code but still it results an error. Can anyone help me out?

Code:

```julia
while user_input != "END"

    print("Enter some input, or END to quit: ")

    user_input = readline() #prompt the user input

end

```

error message:

```julia
ERROR: LoadError: UndefVarError: user_input not defined

Stacktrace:

 [1] top-level scope

   @ f:\Julia Master Course\While loops.jl:1

in expression starting at *:\++++++++(Privacy reason)\While loops.jl:1

```

Code editor: VS code

---

<div class="post-metadata">

**Author:** ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)\
**Post date:** [December 29, 2021, 7:49pm UTC](https://discourse.julialang.org/t/error-loaderror-undefvarerror-user-input-not-defined/73783/2 "2021-12-29T19:49:53Z")

</div>

You haven’t defined user\_input before using it. You probably need another `user_input = readline()` before the while loop

---

<div class="post-metadata">

**Author:** ![stanfordblaze](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stanfordblaze/32/32287_2.png) [@stanfordblaze](https://discourse.julialang.org/u/stanfordblaze)\
**Post date:** [December 29, 2021, 7:51pm UTC](https://discourse.julialang.org/t/error-loaderror-undefvarerror-user-input-not-defined/73783/3 "2021-12-29T19:51:52Z")

</div>

Thanks for the feedback! I was following this tutorial from freecodecamp: [Learn Julia For Beginners – The Future Programming Language of Data Science and Machine Learning Explained](https://www.freecodecamp.org/news/learn-julia-programming-language/)

Can you explain why my code results an error?

---

<div class="post-metadata">

**Author:** ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)\
**Post date:** [December 29, 2021, 7:55pm UTC](https://discourse.julialang.org/t/error-loaderror-undefvarerror-user-input-not-defined/73783/4 "2021-12-29T19:55:55Z")

</div>

> [@Jeff\_Emanuel](#):
>
> You haven’t defined user\_input before using it.

Still holds. The code at your link does not work without predefining user\_input.

```julia
julia> while user_input != "End"
                  print("Enter some input, or End to quit: ")
                  user_input = readline() # Prompt the user for input
              end
ERROR: UndefVarError: user_input not defined

```

vs

```julia
julia> user_input=""; while user_input != "End"
                         print("Enter some input, or End to quit: ")
                         user_input = readline() # Prompt the user for input
                     end
Enter some input, or End to quit:

```

---

<div class="post-metadata">

**Author:** ![stanfordblaze](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stanfordblaze/32/32287_2.png) [@stanfordblaze](https://discourse.julialang.org/u/stanfordblaze)\
**Post date:** [December 29, 2021, 7:58pm UTC](https://discourse.julialang.org/t/error-loaderror-undefvarerror-user-input-not-defined/73783/5 "2021-12-29T19:58:24Z")

</div>

Thanks for the answer! Kind of really excited with Julia so did not catch the mistake. But, have to say, Julia impressed me!
