+ 1

How to divide a sentence into words and make each word a separate member of an array in python.

30th Apr 2022, 5:03 AM
Junior Coder
Junior Coder - avatar
4 Answers
+ 7
Praise Banda , we can use the string method split() like: words = input().split() # this generates a list of words from the sentence that has been input. by using a sentence for input: "this is magic" , the resulting list is: ["this", "is", "magic"] happy coding
30th Apr 2022, 10:25 AM
Lothar
Lothar - avatar
+ 7
You can use function split on spaces. https://code.sololearn.com/cd89N09f7P0R/?ref=app
30th Apr 2022, 8:27 AM
JaScript
JaScript - avatar
+ 2
Thanks for the help. I completely forgot about the split functionšŸ˜…
1st May 2022, 5:46 AM
Junior Coder
Junior Coder - avatar
+ 2
Use .split
1st May 2022, 10:09 PM
Sumit Kumar
Sumit Kumar - avatar