What does .split() do in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What does .split() do in python

26th May 2020, 9:14 PM
Jeremy
Jeremy - avatar
3 Answers
+ 5
Splits a string into list items according to the argument passed a="hellowo,rld" print(a.split(",")) a="hello world spam" print(a.split(" "))
26th May 2020, 9:19 PM
Abhay
Abhay - avatar
+ 4
you will be better off to try it in a code or read the documentation on that which will give you more insight on how the method works, that's just my 2 cent opinion for you
26th May 2020, 10:00 PM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 3
a = 'i like python' b = a.split() print(b) ['i', 'like', 'python'] ------------------- f = banana g = f.split('a') print(g) ['b', 'n', 'n']
26th May 2020, 9:20 PM
Slick
Slick - avatar