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

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