I have been looking for a way to split a string by digits, for instance:
st = "abc4ert"
from string import digits
st = st.split(digits)
--> st = ['abc','ert']
Is there a way to do that (without including the numbers in the list)?
I have been looking for a way to split a string by digits, for instance:
st = "abc4ert"
from string import digits
st = st.split(digits)
--> st = ['abc','ert']
Is there a way to do that (without including the numbers in the list)?
Use Regex.
Ex:
import re
st = "abc4ert"
print(re.findall(r"[A-Za-z]+", st))
Output:
['abc', 'ert']