I'm trying to make a list of dictionaries in python with every letter of a word in each dict. This is my code:
words = ["bella","label","roller"]
list1 = [{}] * len(words)
for i in range(len(words)):
for letter in words[i]:
list1[i][letter] = 0
print(list1)
And this is my output:
[{'b': 0, 'e': 0, 'l': 0, 'a': 0, 'r': 0, 'o': 0},
{'b': 0, 'e': 0, 'l': 0, 'a': 0, 'r': 0, 'o': 0},
{'b': 0, 'e': 0, 'l': 0, 'a': 0, 'r': 0, 'o': 0}]
Why don't I have a different dictionary for every word?