How to split the first N whitespace from a string in Python

1 Answer

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

lst = s.split(" ", 2)

for item in lst:
    print(item)


'''
run:

python
java
c# php c++

'''

 



answered Nov 12, 2017 by avibootz

Related questions

1 answer 132 views
2 answers 188 views
1 answer 167 views
1 answer 150 views
1 answer 140 views
1 answer 136 views
...