Let’s say that I have 3 users and keys will be: ["a", "b", "c", "d"]. I would like to create a dictionary with the list of zeroes but the number of the zeroes in each key should match number of users, so I want to have it like that:
{"a": [0,0,0], "b": [0,0,0], "c": [0,0,0], "d", [0,0,0]}
What is the easiest way of doing this?
>Solution :
users=['u','v','w']
d={k:len(users)*[0] for k in ['a','b','c','d']}
print(d)
gives
{'a': [0, 0, 0], 'b': [0, 0, 0], 'c': [0, 0, 0], 'd': [0, 0, 0]}