These are my inputs
hand = {'*': 1, 'v': 2, 'n': 1, 'i': 1, 'l': 2}
string = 'abc'
I need to replace '*' with each character from string and append the new dict to a list. The output I need is this:
[{'v': 2, 'n': 1, 'i': 1, 'l': 2, 'a': 1}, {'v': 2, 'n': 1, 'i': 1, 'l': 2, 'b': 1}, {'v': 2, 'n': 1, 'i': 1, 'l': 2, 'c': 1}]
This is what I have done and it doesn't work. I have tried a few different approaches but with no success.
del hand['*']
for x in string:
item = {x: 1}
newHand = hand
newHand.update(item)
print(newHand)
list.append(newHand)
newHand.pop(x)
print(list)
The output below is something that I'm trying to avoid:
{'v': 2, 'n': 1, 'i': 1, 'l': 2, 'a': 1, 'b': 1, 'c': 1}
Thanks