I have some code:
dict = {i:j for i in range(1,10,2) for j in range(10,2,-2)}
print(dict)
The output that I get is: {1: 4, 3: 4, 5: 4, 7: 4, 9: 4}
The output that I am expecting is: {1:10,3:8,5:6,7:4,9:2}
While I agree with the keys, what is happening to the values? Why are they stuck at 4? Because when I do range(10,2,-2) this produces 10,8,6,4,2
I have also tried:
dict= {}
for i in range(1,10,2):
for j in range(10,2,-2):
dict[i] = j
print(dict)
But yield the same result. Any ideas why? It must be my range() function.