How to parse a string in Python

2 Answers

0 votes
s = "python c++ c c# java"

words = s.split(' ')

print(words)

'''
run:

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

'''

 



answered Mar 22, 2017 by avibootz
0 votes
s = "python c++ c c# java"

words = s.split(' ')

for word in words:
    print(word)

'''
run:

python
c++
c
c#
java

'''

 



answered Mar 22, 2017 by avibootz
...