Lets say I have a dictionary and list like the below:
l: list = [1,2,3,4]
d: dict = {"Hello": "World"}
I want to copy this dictionary exactly len(l)
times.
I want to eventually create a list of tuples that looks like:
[(1, {"Hello": "World"}),(2, {"Hello": "World"}),(3, {"Hello": "World"}),(4, {"Hello": "World"})]
To create this I imagine I could do:
output: list = list(zip(l, repeated_dicts))
but need to replicate the dictionary the specified number of times in the list.
I tried using itertools.islice
and itertools.cycle
but couldn't quite get it. Any ideas?