How to remove The the specials characters in a Dictionary turned into a string

Viewed 38

I Have a dictionary that look like this : ['A:\','B:\','D:\']

And i want to get this result : ABD

So i tryed the regex :

x = re.findall(r"[a-zA-Z]",str(liste_disque_sel))
    print(x)

But i get : ['A', 'B', 'D'] wich is not ABD.

How can i print the value of a dictionary in a string ? (I have no idea how to fromulate my question pls can you sugest me better ones)

1 Answers

Try this:

import re
s = ['A:\\','B:\\','D:\\']
x = "". join(re.findall(r"[a-zA-Z]",str(s)))
print(x)

Result:

ABD
Related