Jun-06-2017, 05:52 PM
You could also try parsing each individual character, and ignore non-numbers.
>>> x = '4234,093.23' >>> def try_int(ch): ... try: ... _ = int(ch) ... return True ... except ValueError: ... pass ... return False ... >>> ''.join(filter(try_int, x)) '423409323' >>> # the decimal is included, so instead, we should split that out ahead of time... ... >>> left, *_ = x.split(".") >>> left '4234,093' >>> ''.join(filter(try_int, left)) '4234093'Using filter() would probably be a pretty good hint that you got outside assistance, though :p