import string
from itertools import groupby
s = '123ab4 5'
result = [''.join(list(v)) for _, v in groupby(s, key=lambda x: x.isdigit())]
result = [x for x in result if x not in string.whitespace]
result
Splitting a string into a list (but not separating adjacent numbers) in Python