Last Updated : 11 Jul, 2025
We are given a string and our task is to split this string into a list of its individual characters, this can happen when we want to analyze or manipulate each character separately. For example, if we have a string like this: 'gfg' then the output will be ['g', 'f', 'g'].
Using ListThe simplest way to convert a string into a list of characters in Python is to use the built-in list() function, which directly converts each character in the string to a list element.
Python
s = "hello"
a = list(s)
print(a)
['h', 'e', 'l', 'l', 'o']
Explanation:
List comprehension provides a shorter and clearer syntax compared to the traditional loop approach.
Python
s = "hello"
a = [char for char in s]
print(a)
['h', 'e', 'l', 'l', 'o']
Explanation:
The unpacking operator * can be used to split a string into a list of characters in a single line. This approach is compact and works well for quickly converting a string to a list.
Python
s = "hello"
a = [*s]
print(a)
['h', 'e', 'l', 'l', 'o']
Explanation: [ *s ] unpacks each character in the string s into a list.
Using a LoopWe can also use a simple loop (for loop) to convert string into list of characters. This method is useful when we want to include additional logic within the loop.
Python
s = "hello"
a = []
for char in s:
a.append(char)
print(a)
['h', 'e', 'l', 'l', 'o']
Explanation: This code splits the string s = "hello" into a list of characters by iterating through each character and appending it to the list a.
Related Articles:
Python Program to Split String into List of Characters
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4