I have two lists of different lengths. One list has a fixed number of values that are to be used later as keys. The number of values in the second list can increase arbitrarily. The goal is to use the first list as a key for the second list again and again, depending on how many values list "a" gets.
d = ["a","b","c"]
a = [1,2,3,4,5,6,7]
In the end it should look like this:
c = {"a":1,"b":2,"c":3,"a":4,"b":5,"c"=6,"a":7}
The keys from "d" are to be repeated again and again for the values in "a" as long as there are values in "d". Thank you all. :)
You can use 'cycle from itertools' itertools - cycle module for you desired result. if you have two unequal length list.
from itertools import cycle
d = ["a","b","c"]
a = [1,2,3,4,5,6,7]
# zipping in cyclic if shorter length
result = dict(zip(a, cycle(d)))
# printing resultant dictionary
print("resultant dictionary : ", str(result))