How to use split in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How to use split in python

Split for 3 strings

8th Feb 2021, 9:14 AM
Nabeel Ahmed
Nabeel Ahmed - avatar
5 Answers
+ 7
Have you got to this part? if not, then just continue study Python tutorial 👍 https://www.sololearn.com/learn/Python/2456/
8th Feb 2021, 9:16 AM
Ipang
+ 9
Nabeel Ahmed , maybe you mean how to split a string with 3 words? this can be done like: txt ="hello my world" result = txt.split() the string is now split and stored in list "result": ['hello', 'my', 'world']
8th Feb 2021, 9:19 AM
Lothar
Lothar - avatar
+ 7
Parameters: ---> string.split(character) character ---> whitespace by default x = "One Two Three" print(x.split()) >> ["One", "Two", "Three"] x = "One Two Three" print(x.split("T")) >> ["One ", "wo ", "hree"]
8th Feb 2021, 9:16 AM
noteve
noteve - avatar
+ 3
Thank you very much for your help
8th Feb 2021, 9:17 AM
Nabeel Ahmed
Nabeel Ahmed - avatar
+ 3
Ok
8th Feb 2021, 9:20 AM
Nabeel Ahmed
Nabeel Ahmed - avatar