python - removing substring -


can please hint mistake. im trying remove numbers string. findall succefully finds number replace not replace them empty string. here code:

import re x = 'john2345 can5 code python3' = re.findall('\d{1,9}', x) x.replace(extra, '') x 

and here error:

typeerror                                 traceback (most recent call last) <ipython-input-334-bfc161d88f65> in <module>()       2 x = 'ererf ergg5 erg 545 eeg'       3 = re.findall('\d{1,9}', x) ----> 4 x.replace(extra, '')       5 x  typeerror: can't convert 'list' object str implicitly 

cheers, sia

use re.sub()

re.sub(r'\d+' ,'', x) 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -