# Changes in for-loop don't apply outside loop

**URL:** <https://discourse.julialang.org/t/changes-in-for-loop-dont-apply-outside-loop/94670>\
**Category:** General Usage\
**Created:** [February 15, 2023, 7:50am UTC](https://discourse.julialang.org/t/changes-in-for-loop-dont-apply-outside-loop/94670 "2023-02-15T07:50:56Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![uniment](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uniment/32/24532_2.png) [@uniment](https://discourse.julialang.org/u/uniment)\
**Post date:** [February 16, 2023, 6:36am UTC](https://discourse.julialang.org/t/changes-in-for-loop-dont-apply-outside-loop/94670/4 "2023-02-16T06:36:23Z")

</div>

Works as expected.

```julia
julia> value = [Dict("price"=>Dict("price"=>x)) for x in [200.0, 200.0, 200.0, 200.0, 200.0]]
       filtered_valid_perm_array = [[2.0, 10.0, 20.0, 30.0, 40.0]]
       for good_perm in filtered_valid_perm_array
       println(good_perm)
       dupl_of_value = deepcopy(value)
           for jj in 1:length(good_perm)
           dupl_of_value[jj]["price"]["price"] = good_perm[jj]
               if jj == 1
                   println("good: ", dupl_of_value[jj]["price"]["price"])
               end
           end
           println("1 bad: ", dupl_of_value[1]["price"]["price"])
           println("1 bad: ", dupl_of_value[2]["price"]["price"])
       end
[2.0, 10.0, 20.0, 30.0, 40.0]
good: 2.0
1 bad: 2.0
1 bad: 10.0

```

Are you sure you’re not mistaking something else?

Can you make a minimum working example (MWE) of _runnable_ code that shows the issue you’re concerned about, as described here: [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757)?

---

_[View the full topic](https://discourse.julialang.org/t/changes-in-for-loop-dont-apply-outside-loop/94670)._
