Convert string to list of characters Python

In this Python string tutorial, you will learn how to convert a string to a list of characters in Python.

# Create a string
S = "Machine"

# Convert string into list of characters
L = list(S)

# Print list of characters
print(L)

# Display the type of L
print(type(L))

Output:

['M', 'a', 'c', 'h', 'i', 'n', 'e']
<class 'list'>

Free learning resources: AiHintsCodeAllow

Leave a Comment

Your email address will not be published.