vikky 2405 vikky 2405 - 13 days ago 5
Python Question

How to replace a dot with a string in a python list

my_list = ['b','.','.']

expected_list = ['b','.','w']

May be simple, moving into python recently so any suggestions would be fine


If you are replacing every occurrence of '.' with 'w' then I would just suggest:

for n, i in enumerate(my_list):
    if i == '.':
        my_list[n] = 'w'

Here is the documentation for how to use the enumerate() function: