How to split a string into a list by delimiter (separator) in Python

1 Answer

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

lst = s.split(":")

print(lst[0])
print(lst[2])

print("---")

for item in lst:
    print(item)


'''
run:

python
c#
---
python
java
c#
php
c++

'''

 



answered Nov 12, 2017 by avibootz
...