# Values from Dictionary

**URL:** <https://discourse.julialang.org/t/values-from-dictionary/32996>\
**Category:** New to Julia\
**Created:** [January 5, 2020, 3:29pm UTC](https://discourse.julialang.org/t/values-from-dictionary/32996 "2020-01-05T15:29:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ar12y](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@ar12y](https://discourse.julialang.org/u/ar12y)\
**Post date:** [January 5, 2020, 3:29pm UTC](https://discourse.julialang.org/t/values-from-dictionary/32996/1 "2020-01-05T15:29:20Z")

</div>

hi,  
I have the following dictionary called “states”:

```julia
states=Dict{Any,Any}((0, 0) => Array{Any,1}[[[0], (0, 0), Any[0, 0]], [[1], (1, 0), Any[1, 1]]],(1, 0) => Array{Any,1}[[[0], (0, 1), Any[1, 0]], [[1], (1, 1), Any[0, 1]]],(0, 1) => Array{Any,1}[[[0], (0, 0), Any[1, 1]], [[1], (1, 0), Any[0, 0]]],(1, 1) => Array{Any,1}[[[0], (0, 1), Any[0, 1]], [[1], (1, 1), Any[1, 0]]])

```

and I want to take the values of states and define them as “val\_0” and “val\_1” so that I get the following output:

```julia
val_0=[[0], (0, 0), Any[0, 0]] 
val_1=[[1], (1, 0), Any[1, 1]]

```

(so val\_0 and val\_1 are from (0, 0) =\> …).

(In the next step val\_0 shall be:  
`val_0=[[0], (0, 1), Any[1, 0]] `  
`val_1= [[1], (1, 1), Any[0, 1]]`  
from key (1, 0) and so on).

---

<div class="post-metadata">

**Author:** ![findmyway](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/findmyway/32/4946_2.png) [@findmyway](https://discourse.julialang.org/u/findmyway)\
**Post date:** [January 5, 2020, 4:01pm UTC](https://discourse.julialang.org/t/values-from-dictionary/32996/2 "2020-01-05T16:01:06Z")

</div>

Hey @ar12y

Is this what you want?

```julia
for v in values(states)
       val_0, val_1 = v
       # do something
end

```

---

<div class="post-metadata">

**Author:** ![tro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tro3/32/12355_2.png) [@tro3](https://discourse.julialang.org/u/tro3)\
**Post date:** [January 5, 2020, 4:06pm UTC](https://discourse.julialang.org/t/values-from-dictionary/32996/3 "2020-01-05T16:06:34Z")

</div>

@ar12y, I think you want:

```julia
for (val_0, val_1) in values(states)
    println(val_0)
    println(val_1)
    println()
end

```

Hope this helps.

---

<div class="post-metadata">

**Author:** ![ar12y](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@ar12y](https://discourse.julialang.org/u/ar12y)\
**Post date:** [January 5, 2020, 4:10pm UTC](https://discourse.julialang.org/t/values-from-dictionary/32996/4 "2020-01-05T16:10:14Z")

</div>

@findmyway , @tro3

this is exactly the solution I was looking for.  
Thank you for your replies.
