Update setuptools under windows
pip install setuptools --upgrade --ignore-installed
format number to percentage string
"{:.2%}".format(x)
remove special characters from string
You should apply the re.sub function on single objects, not on lists.
files_cleaned = [re.sub(r"[-()\"#/@;:<>{}`+=~|.!?,]", "", file) for file in files]
If you only want to accept alphanumerical characters you can do this instead:
files_cleaned = [re.sub(r"[^a-zA-Z0-9]", "", file) for file in files]
remove element from list by value
To remove an element’s first occurrence in a list, simply use list.remove:
>>> a = ['a', 'b', 'c', 'd']
>>> a.remove('b')
>>> print(a)
['a', 'c', 'd']
Mind that it does not remove all occurrences of your element. Use a list comprehension for that.
>>> a = [10, 20, 30, 40, 20, 30, 40, 20, 70, 20]
>>> a = [x for x in a if x != 20]
>>> print(a)
[10, 30, 40, 30, 40, 70]