-4

I'm using PYTHON3 my output is like this "200:Just be close at Hand" I only need the 200 is there a way to remove the strings and symbol? Thanks

MIZU
  • 1

2 Answers2

0

You can use regular expressions to remove anything that's not a number

>>> import re
>>> s = "200:Just be close at Hand"
>>> re.sub(r'[^\d]', "", s)
'200'
>>> s = "200:Just be close 33 at Hand 342"
>>> re.sub(r'[^\d]', "", s)
'20033342'
C. Ramseyer
  • 2,322
  • 2
  • 18
  • 22
0
>>> txt = "200:Just be close at Hand"
>>> txt.split(":")[0]
'200'