In this Python string tutorial, you will learn how to convert string to list in Python.
Method 1: list() function
It is used to convert any iterable into a list.
# Create a string S = "AiHints" # Convert the string into list L = list(S) # Display list print(L)
Output:
['A', 'i', 'H', 'i', 'n', 't', 's']
Method 2: split() function
It is used to split the string at a specific character.
# Create a string
S = 'A,i,H,i,n,t,s'
# Convert the string into list
L = S.split(',')
# Display list
print(L)Output:
['A', 'i', 'H', 'i', 'n', 't', 's']


