Convert string to list of words Python

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

# Create a string
S = "AiHints is a website"

# Convert string into list of words
L = S.split()

# Print list of words

# Display the type of L


['AiHints', 'is', 'a', 'website']
<class 'list'>

Free learning resources: AiHintsCodeAllow

Leave a Comment

Your email address will not be published.