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 216 views
2 answers 306 views
1 answer 254 views
1 answer 236 views
1 answer 217 views
1 answer 230 views
...