# Unable to find values of variable in the code

``````>>> A0= dict(zip(('a','b','c','d','e'),(1,2,3,4,5)))
>>> A1= range(10)
>>> A2= sorted([i for i in A1 if i in A0])
>>> A3= sorted([A0[s] for s in A0])
>>> A4= [i for i in A1 if i in A3]
>>> A5= {i:i*i for i in A1}
>>> A6= [[i,i*i] for i in A1]
A0,A1,A2,A3,A4,A5,A6

```I am having difficulty in finding values of the variable in the above code. Is the code wrong? Can anyone help!``````

Which parts specifically are not working for you?

`A2` is creating an empty list because when working with a dictionary the lookup is by ‘key’ not by ‘value’ so the values `0, 1, 2, 3, 4, 5, 6, 7, 8, 9` (the values of `i` in the code for `A2`) do not match any of the keys in `A0` which are `'a', 'b', 'c', 'd', 'e'`. Dictionaries have a built-in method `<dict>.values()` for generating an iterable of all the values contained in the dictionary. So you could do this:

``````>>> A2 = sorted([i for i in A1 if i in A0.values()])
>>> A2
[1, 2, 3, 4, 5]
``````

i can see them?.. not sure what ya tryin?

``````A0= dict(zip(('a','b','c','d','e'),(1,2,3,4,5)))
A1= range(10)
A2= sorted([i for i in A1 if i in A0])
A3= sorted([A0[s] for s in A0])
A4= [i for i in A1 if i in A3]
A5= {i:i*i for i in A1}
A6= [[i,i*i] for i in A1]
a= [A0,A1,A2,A3,A4,A5,A6]
print("initializing...\n")
print(*a, sep = "\n")
print("\n value check: A3-item 2 ...\n")
print(A3)
``````

``````A0= {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}
A1= range(0, 10)
A2= []
A3= [1, 2, 3, 4, 5]
A4= [1, 2, 3, 4, 5]
A5= {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81}
A6= [[0, 0], [1, 1], [2, 4], [3, 9], [4, 16], [5, 25], [6, 36], [7, 49], [8, 64], [9, 81]]
``````

Now to find out what happened. A0 zips ‘a’ with 1, ‘b’ with 2, and so on. This results in tuples, which the call to dict() then turns into a dictionary by using these as keys and values.

A1 gives us a range object with start=0 and stop=10.

A2 checks each item in A1- does it exist in A0 as well? If it does, it adds it to a list. Finally, it sorts this list. Since no items exist in both A0 and A1, this gives us an empty list.

A3 takes each key in A0 and returns its value. This gives us the list [1,2,3,4,5].

A4 checks each item in A1- does it exist in A3 too? If it does, it adds it to a list and returns this list.

A5 takes each item in A1, squares it, and returns a dictionary with the items in A1 as keys and their squares as the corresponding values.

A6 takes each item in A1, then returns sublists containing those items and their squares- one at a time.

Have a Happy learning!