How to get number of elements in list of lists?
L = ['a,b,c,d','e,f,g,h,i','j,k,l',]
I want to find how many elements in the first list in L.
a,b,c,d = 4 elements
e,f,g,h,i = 5 elements
j,k,l = 3 elements
For each string in L you could use the str.count method to count the number of commas and add one:
In [277]: L = ['a,b,c,d','e,f,g,h,i','j,k,l',]
In [278]: [item.count(',')+1 for item in L]
Out[278]: [4, 5, 3]
[[a,b,c,d],[e,f,g,h,i],[j,k,l]]and would have a different answer (which would belen(L[0])).