translate() takes exactly one argument (2 given) in python error
<pre><code>import os
import re

def rename_files():
    # get the files from dir
    file_list=os.listdir(r"C:\OOP\prank")
    print(file_list)
    saved_path=os.getcwd()
    print("current working directory"+saved_path)
    os.chdir(r"C:\OOP\prank")
    #rename the files
    for file_name in file_list:
        print("old name-"+file_name)
        #print("new name-"+file_name.strip("0123456789"))
        os.rename(file_name,file_name.translate(None,"0123456789"))
        os.chdir(saved_path)

rename_files()
</code></pre>

<p>Here error is showing due to translate line ...help me what to do next ..I am using translate to remove the digit from filename.</p>

<pre><code>Traceback (most recent call last):
    File "C:\Users\vikash\AppData\Local\Programs\Python\Python35-  32\pythonprogram\secretName.py", line 17, in &lt;module&gt;
rename_files()
      File "C:\Users\vikash\AppData\Local\Programs\Python\Python35-  32\pythonprogram\secretName.py", line 15, in rename_files
     os.rename(file_name,file_name.translate(None,"0123456789"))
     TypeError: translate() takes exactly one argument (2 given)
</code></pre>

<p>Instead of translate why not just do this:</p>

<pre><code>os.rename(file_name,''.join([i for i in file_name if not i.isdigit()]))
</code></pre>

python string file