Split line of text into words per line | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Split line of text into words per line

how to write code using python3 that will input a line of text, split it into words, and display these words one per line.

13th Nov 2017, 2:22 PM
Earl
2 Answers
+ 1
phrase = input('enter a phrase') phrase = phrase.split(' ') for x in phrase: print(phrase[x]) print('\n')
13th Nov 2017, 5:16 PM
Etabeta1🇮🇹
Etabeta1🇮🇹 - avatar
0
Take a look at the python3 docs for the input function and the split method both can help you out with this and for more advanced techniques take a look at the re module.
13th Nov 2017, 3:04 PM
Joseph David Zamora Murillo
Joseph David Zamora Murillo - avatar