What is the use of split() in python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

What is the use of split() in python?

26th Apr 2021, 12:59 PM
Kishore Kumar BP
Kishore Kumar BP - avatar
6 Answers
+ 4
Kishore Kumar BP The split() method splits a string into a list. You can specify the separator, default separator is any whitespace. Note: When maxsplit is specified, the list will contain the specified number of elements plus one. https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/ref_string_split.asp#:~:text=The%20split()%20method%20splits,number%20of%20elements%20plus%20one.
27th Apr 2021, 9:48 PM
❤️😍Prerana😍❤️
❤️😍Prerana😍❤️ - avatar
+ 5
Thanks for the answer 😁
26th Apr 2021, 2:36 PM
Kishore Kumar BP
Kishore Kumar BP - avatar
+ 5
Thanks ❤️😍Prerana😍❤️ for additional info 😁
29th Apr 2021, 5:56 AM
Kishore Kumar BP
Kishore Kumar BP - avatar
+ 2
To split string into list . "Hello world" to convert the string to ["hello","world"] you may use "Hello world". split(" ")
26th Apr 2021, 1:08 PM
TOLUENE
TOLUENE - avatar
+ 2
Welcome ☺️ Kishore Kumar BP
29th Apr 2021, 5:58 AM
❤️😍Prerana😍❤️
❤️😍Prerana😍❤️ - avatar
+ 1
The split method of string splits a string to a list. Ex. 'abcbd'.split('b') >> ['a' , 'c' , 'd'] Here the string abcbd is divided taking 'b' as the point of division.
26th Apr 2021, 2:06 PM
Md. Faheem Hossain
Md. Faheem Hossain - avatar