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 ?
Answers:
Try this:
import re
s = ['A:\','B:\','D:\']
x = "". join(re.findall(r"[a-zA-Z]",str(s)))
print(x)
Result:
ABD
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 ?
Try this:
import re
s = ['A:\','B:\','D:\']
x = "". join(re.findall(r"[a-zA-Z]",str(s)))
print(x)
Result:
ABD