How To Convert Comma Separated String To List In Python
Last updated January 31, 2024 by Jarvis Silva
Looking for a way to convert comma separated string to list in python then you are at the right place today in this tutorial we will see how can we convert a comma separated string to list using methods in python.
Example
Comma Separated String: โH,E,L,L,L,0โ
Convert To List: ['H', 'E', 'L', 'L', 'O']
Python Code To Convert Comma Separated String To List
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, you can see it by yourself by running the above code on your computer or use an online python compiler, 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, I hope you found this program helpful.
Here are more python tutorials you may find interesting:
- Convert Wav to Mp3 in python with code.
- Convert Rupee to Paise in python.
- Convert days to hours in python.
- Convert minutes to hours and minutes in python.
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 ๐