How to split string by one or more adjacent spaces in Python

1 Answer

0 votes
import re

s = 'python         java  c++ c         swift'

s = re.split(' +', s)

print(s)



'''
run:

['python', 'java', 'c++', 'c', 'swift']

'''

 



answered Oct 26, 2020 by avibootz
...