I have a string str = "abcd"
I want to replace the 1st char of str with "X", append to empty list, replace the 2nd char with "X", append to list, repeat until all elements have been replaced, resulting in the following list of lists:
[['N', 'b', 'c', 'd'],
['a', 'N', 'c', 'd'],
['a', 'b', 'N', 'd'],
['a', 'b', 'c', 'N']]
I've tried:
str = "abcd"
bla = list(str)
blabla = [bla]*len(bla)
for i,e in enumerate(blabla):
e[i]="N"
I didnt "append" because I dont know how to in this situation. The unwanted result is:
[['N', 'N', 'N', 'N'],
['N', 'N', 'N', 'N'],
['N', 'N', 'N', 'N'],
['N', 'N', 'N', 'N']]
What is the best solution in python 3.5?