Python Split String into List of Characters Example
Today our leading topic is python convert string to list of characters. This post will give you simple example of how to convert string to list in python. I explained simply step by step how to split a string in python by character. you can understand a concept of python split string into list of characters.
There are several ways to convert strings into a list of characters in python. we will use split() and strip() functions to convert string into list. so let's see the below examples.
You can use these examples with python3 (Python 3) version.
let's see below a simple example with output:
myString = "Site ItSolutionStuff.com" # Convert String into List newList = list(myString.strip(" ")) print(newList)
['S', 'i', 't', 'e', ' ', 'I', 't', 'S', 'o', 'l', 'u', 't', 'i', 'o', 'n', 'S', 't', 'u', 'f', 'f', '.', 'c', 'o', 'm']
myString = "ItSolutionStuff.com is a best site!" # Convert String into List newList = myString.split(" ") print(newList)
['ItSolutionStuff.com', 'is', 'a', 'best', 'site!']
myString = "One,Two,Three,Four,Five" # Convert String into List newList = myString.split(",") print(newList)
['One', 'Two', 'Three', 'Four', 'Five']
I hope it can help you...
We are Recommending you
- How to Remove Duplicate Values from List in Python?
- How to Get Unique Elements from List in Python?
- How to Remove null Values from the List in Python?
- Python Remove Empty String from List Example
- Python Get Second Last Element of List Example
- How to Get the Last Element of a List in Python?
- How to Get First Element of List in Python?
- How to Remove Last Element from List in Python?
- How to Remove First Element from List in Python?
- Python List Remove Element by Value Example
- Python List Remove Element by Index Example
- Python Delete File if Exists Example
- Python Post Request with Basic Authentication Example