# Python | Splitting a string into a list of characters

Learn examples from DataCamp guru:

Method # 1: Using the comprehension list + `split()`
A combination of the above functions can be used to accomplish this task. In this we iterate over the list using a list comprehension and can split using split ().

 ` # Python3 code to demonstrate how it works ` ` # Convert the list of strings to a nested list of characters ` ` # using split () + list comprehension `   ` # initialize list ` ` test_list ` ` = ` ` [` ` "a, b, c" ` `, ` ` "gfg, is, best" ` `, ` `" 1, 2, 3 "` `] ` ` `  ` # print original list ` ` print ` ` (` `" The original list: "` ` + ` ` str ` ` (test_list)) ` `   # Convert list of strings to nested list of characters # using split () + list comprehension ```` res = [char.split ( `,` ) for char in test_list]   # print result print ( "List after performing conversion:" + str (res)) ```

Output:

The original list: [`a, b, c`, `gfg, is, best`, `1, 2, 3 `]
List after performing conversion: [[` a `,` b `,` c `], [` gfg `,` is `,` best `], [` 1 `,` 2 `,` 3 `]]

Method # 2: Using ` map () + split () ` + lambda
Combination of the above functions can be used to accomplish this task. In this we are doing the iteration task using map () and the lambda function is used to apply split logic using split () to all the elements of the list.

 ` # Python3 code to demonstrate how it works ` ` # Convert a list of strings to a nested list of characters ` ` # using map () + split () + lambda `   ` # initialize the list ` ` test_list ` ` = ` ` [` `" a, b, c "` `, ` `" gfg, is, best "` `, ` ` "1, 2, 3" ` `] `   ` # print original list ` ` print ` ` (` ` "The original list:" ` ` + ` ` str ` ` (test_list)) `   ` # Convert a list of strings to a nested list of characters ` ` # using map () + split () + lambda ` ` res ` ` = ` ` list ` ` (` ` map ` ` (` ` lambda ` ` ele: ele.split (` ``, ` ` `), test_list)) `   ` # print result ` ` print ` ` (` “List after performing conversion:” ` + ` ` str ` ` (res)) `

Exit:

The original list: [`a, b, c`, `gfg, is, best`, `1, 2, 3`]
List after performing conversion: [[`a`, `b`, `c`], [`gfg`, `is`, `best`], [`1`, `2`, `3`]]

Learn examples from DataCamp guru: