Explore

Close
Python Programs Share

How To Convert Comma Separated String To List In Python

Convert Comma Separated String To List In Python

Looking for a way to convert comma separated string to list in python then you are at the right place today in this tutorial I will show you how to convert comma separated string to list in python.

Converting comma separated string to a list in python is very easy to do and simple. I will show you the exact way to convert it so read this guide till the end.

Before we see how to do it in code let’s see some examples of how this program will work and convert.

Example


Comma Separated String: ‘H,E,L,L,L,0’
Convert To List: ['H', 'E', 'L', 'L', 'O']

Above is the example of how this program will work. I hope you understood let’s see how to convert it in code.

Convert Comma Separated String To List In Python Code


string_ = 'H,E,L,L,O'
list_ = string_.split(",")
print(string_.split(','))

We have used the split() method in python which converts a string to a list. I said that it was a simple tutorial. I hope you got it.

You can run the above code on your computer or use an online python compiler to test it now. If you don’t have python installed you can refer to this guide: Install and setup python.

Output


['H', 'E', 'L', 'L', 'O']

Above is the example output of the program as you can see it converted the comma separated string to list in python programming I hope you successfully ran the program.

Summary

This was a short python tutorial on how to convert a comma separated string to a list in python programming. I hope you found this tutorial helpful and useful.

Here are more python tutorials you may find interesting:

I hope you found what you were looking for and do share it with your friends who need this program and join our Telegram channel for future blog updates.

Thanks for reading, have a nice day 🙂