+ 1
I want to change the values of dictionary by using range in List comprehension is this possible?
l = dict([(key,value) for key in range(1,7) for value in range(5,10)]). - -Output : {1: 9, 2: 9, 3: 9, 4: 9, 5: 9, 6: 9} want to change the value by using range.
2 Answers
+ 2
Do you mean like this?
d = dict([e for e in zip(range(1,7), range(5,11))])
Output: {1:5, 2:6, 3:7, 4:8, 5:9, 6:10}
+ 2
Ani Jona š Yes,thank you