How to replace all spaces by underscores and remove all the parentheses without using replace() function?
<p>Here is what I did. I know this is definitely wrong. I'd like to know how to make this one work? Thx!</p>

<pre><code>import re
def demicrosoft (fn):

"""Clean up a file name.

Remove all parentheses and replace all spaces by underscores.

Params: fn (string): 
Returns: (string) clean version of fn
"""

fn = re.sub('[()]', '', fn)
for ch in ['']:
    fn = fn.translate(ch, "_")
return fn

print(demicrosoft('Quercus stellata (26).jpg'))
</code></pre>

<p>From Zen of Python: Readability counts!</p>

<pre><code>def demicrosoft (fn):
    dest = ""
    for char in fn:
        if char == ' ':
            dest += '_'
        elif char not in '()':
            dest += char
    return dest
</code></pre>

python replace removeall