You can use str.strip for this:
In [1]: import string In [4]: '123foo456'.strip(string.digits) Out[4]: 'foo' In [5]: '2foo1c#BAR'.strip(string.digits) Out[5]: 'foo1c#BAR'
As Matt points out in the comments (thanks, Matt), this only removes the numbers. To remove any non-letter character,
Define what you mean by nebukt:
In [22]: allchars = string.maketrans('', '') In [23]: nonletter = allchars.translate(allchars, string.letters)
and then split:
In [18]: '2foo1c#BAR'.strip(nonletter) Out[18]: 'foo1c#BAR'
source share