How can i split a string? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How can i split a string?

Like "{precious}" to "{p r e c i o u s}" something like that

18th Aug 2018, 7:55 PM
Olusola Precious
Olusola Precious - avatar
3 Answers
+ 3
str='precious' lst=list(str) print(*lst) or print(*[i for i in 'precious'])
18th Aug 2018, 7:59 PM
Louis
Louis - avatar
+ 3
#To split a sentence into a list of words sentence='To split a sentence into a list of words.' sentence_list=sentence.split() print(sentence_list,'\n') #To split the words in the sentence into lists word_list_in_Sentence_list=[list(word) for word in sentence_list] print(word_list_in_Sentence_list,'\n') [print(' '.join(word),end=' ') for word in sentence_list]
18th Aug 2018, 8:20 PM
Louis
Louis - avatar
+ 1
x = input() for each in x: print(each, end=' ')
18th Aug 2018, 9:09 PM
Steven M
Steven M - avatar