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 215 views
2 answers 305 views
1 answer 253 views
1 answer 235 views
1 answer 214 views
1 answer 230 views
...