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 Ameur

Enthusiastic Network Engineer specializing in Cisco ACI, passionate about solving challenges. A lifelong learner who loves gaining and sharing knowledge. Profile: https://www.linkedin.com/in/bilel-ameur-71116b2b5
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