How to replace a dot with a string in a python list
<pre><code>my_list = ['b','.','.']

expected_list = ['b','.','w']
</code></pre>

<p>May be simple, moving into python recently so any suggestions would be fine</p>

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

<pre><code>for n, i in enumerate(my_list):
    if i == '.':
        my_list[n] = 'w'
</code></pre>

<p>Here is the documentation for how to use the enumerate() function: <a href="https://docs.python.org/2/library/functions.html#enumerate" rel="nofollow">https://docs.python.org/2/library/functions.html#enumerate</a></p>

python python-2.7