How to split list in python?

Splitting list is an important task in lists in python. Here we’ll see some example how we can split a list in python.
e.g.,
l=['a', 'b', 'c', 'd'] a=",".join(l) print(a)

In the next example we’ll see how we can split the list into two parts.
e.g.,
a=['1', '2', '3', '4'] l=len(a) m=l//2 a1=a[:m] print(a1) a2=a[m:] print(a2)

This is how we can split list in python.
Subscribe
Login
Please login to comment
0 Discussion