I have an input file containing lines like the following:
"Kansas City Chiefs 42"
Each line contains a random number of spaces between the words and the numbers. I am trying to identify a way that I can slice the two values (word portion and number portion). My ideal output would be:
"Kansas City Chiefs"
"42"
Any ideas?
Checkout this regex:
import re your_string = "Kansas City Chiefs 42" items = re.split(r's+(?=d)|(?<=d)s+', your_string) print(items)
you got:
['Kansas City Chiefs', '42']
1.4m articles
1.4m replys
5 comments
57.0k users