Convert Text to a List in Python

Convert String to a List in Python

In order to convert String to a list in Python, we will use the split() method.

It’s simple:

All we have to do is to specify the delimiter, in this example, the delimiter is “,”

a = "Hello, LearnDuty!"
print(a.split(","))

Output:

['Hello', ' LearnDuty!']
Bilel

Bilel

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x