I know that re.sub(pattern, repl,text) can substitute when pattern matches, and then return the substitute.
re.sub(pattern, repl,text)
My code is:
text = re.sub(p
"Whether string contains numbers":
for text1 in ('abc123def', 'adsafasdfafdsafqw', 'fsadfoi81we'): print("Text %s %s numbers." % ((text1, ) + ( ('does not contain',) if not any(c.isdigit() for c in text1) else ('contains',)) ))