Splitting String to List of Characters - Python Last Updated : 30 Jan, 2025 Comments Improve Suggest changes Like Article Like Report We are given a string, and our task is to split it into a list where each element is an individual character. For example, if the input string is "hello", the output should be ['h', 'e', 'l', 'l', 'o']. Let's discuss various ways to do this in Python.Using list()The simplest way to split a string into individual characters is by using the list() function. Python s = "python" # Splitting into characters res = list(s) print(res) Output['p', 'y', 't', 'h', 'o', 'n'] Explanation:list(s) converts the string into a list of characters.Each character in s becomes an individual element in result.Let's explore some more ways and see how we can split a string into a list of characters.Table of ContentUsing List ComprehensionUsing map()Using re.findall()Using List ComprehensionList comprehension provides a compact way to iterate over the string and extract characters. Python s = "python" # Splitting into characters res = [char for char in s] print(res) Output['p', 'y', 't', 'h', 'o', 'n'] Explanation:The for loop extracts each character from s into a list.This approach is useful when additional conditions or transformations are needed.Using map()map() function applies str on each character of the string and returns an iterable, which we convert to a list. Python # Initializing string s = "python" # Splitting into characters res = list(map(str, s)) print(res) Output['p', 'y', 't', 'h', 'o', 'n'] Explanation:map(str, s) processes each character individually.The result is converted to a list for easier manipulation.Using re.findall()Regular expressions can be used to match individual characters in the string. Python import re # Initializing string s = "python" # Splitting into characters res = re.findall(r'.', s) print(res) Output['p', 'y', 't', 'h', 'o', 'n'] Explanation:re.findall(r'.', s) matches each character separately.This approach is useful when additional pattern-based filtering is needed. Comment More infoAdvertise with us Next Article Splitting String to List of Characters - Python manjeet_04 Follow Improve Article Tags : Python Python Programs Python list-programs Python string-programs Practice Tags : python Similar Reads Split String into List of characters in Python 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 t 2 min read Split String of list on K character in Python In this article, we will explore various methods to split string of list on K character in Python. The simplest way to do is by using a loop and split().Using Loop and split()In this method, we'll iterate through each word in the list using for loop and split it based on given K character using spli 2 min read Python | K Character Split String The problems and at the same time applications of list splitting is quite common while working with python strings. Some characters are usually tend to ignore in the use cases. But sometimes, we might not need to omit those characters but include them in our programming output. Letâs discuss certain 4 min read Python | Splitting string list by strings Sometimes, while working with Python strings, we might have a problem in which we need to perform a split on a string. But we can have a more complex problem of having a front and rear string and need to perform a split on them. This can be multiple pairs for split. Let's discuss certain way to solv 3 min read Python | Split flatten String List Sometimes, while working with Python Strings, we can have problem in which we need to perform the split of strings on a particular deliminator. In this, we might need to flatten this to a single String List. Let's discuss certain ways in which this task can be performed. Method #1 : Using list compr 7 min read Get Last N characters of a string - Python We are given a string and our task is to extract the last N characters from it. For example, if we have a string s = "geeks" and n = 2, then the output will be "ks". Let's explore the most efficient methods to achieve this in Python.Using String Slicing String slicing is the fastest and most straigh 2 min read Ways to split strings on Uppercase characters - Python Splitting strings on uppercase characters means dividing a string into parts whenever an uppercase letter is encountered.For example, given a string like "CamelCaseString", we may want to split it into ["Camel", "Case", "String"]. Let's discuss different ways to achieve this.Using Regular Expression 3 min read Split string on Kth Occurrence of Character - Python The task is to write Python program to split a given string into two parts at the KáµÊ° occurrence of a specified character. If the character occurs fewer than K times return the entire string as the first part and an empty string as the second part. For example, in the string "a,b,c,d,e,f", splitting 3 min read Python | Split string in groups of n consecutive characters Given a string (be it either string of numbers or characters), write a Python program to split the string by every nth character. Examples: Input : str = "Geeksforgeeks", n = 3 Output : ['Gee', 'ksf', 'org', 'eek', 's'] Input : str = "1234567891234567", n = 4 Output : [1234, 5678, 9123, 4567] Method 2 min read Python | Rear stray character String split Python3 # Python3 code to demonstrate working of # Rear stray character String split # Using list comprehension # initializing string test_str = 'gfg, is, best, ' # printing original string print("The original string is : " + test_str) # Rear stray character String split # Using list compr 5 min read Like