Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,094 questions

40,775 answers

573 users

How to split a string into words in Python

3 Answers

0 votes
s = 'python programming language'

words = s.split(" ")

for w in words:
    print(w)

'''
run:

python
programming
language

'''

 





answered Feb 5, 2017 by avibootz
0 votes
import re

s = '-python,,, programming... language!'

print(re.findall(r"[\w']+", s))

'''
run:

['python', 'programming', 'language']

'''

 





answered Feb 5, 2017 by avibootz
0 votes
import re

s = '-python,,, programming... language!'

words = re.findall(r"[\w']+", s)

for w in words:
    print(w)

'''
run:

python
programming
language

'''

 





answered Feb 5, 2017 by avibootz

Related questions

1 answer 38 views
1 answer 51 views
2 answers 104 views
2 answers 116 views
...