How to Convert a String to a List of Words in Python

sentence = "Python programming is fun"
word_list = sentence.split()
print(f"Sentence: {sentence}\nWord List: {word_list}")

Output:

Sentence: Python programming is fun
Word List: [‘Python’, ‘programming’, ‘is’, ‘fun’]

Leave a Comment

Your email address will not be published.