How can i print the value of a dictionary in a string with a regex?

Question:

I Have a list that look like this : [‘A:’,’B:’,’D:’]

And I want to get this result : ABD

So i tryed the regex :

liste_disque_sel =  ['A:\','B:\','D:\']
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 ?

Asked By: akmot

||

Answers:

Try this:

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

Result:

ABD
Answered By: user56700
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.