I have a list of lists which contains strings. Like the following:
[['apple', 'pear', 'apple'], ['apple', 'apple'], ['apple', 'pear', 'apple','apple', 'pear', 'apple']]
There are about 2000 lists in this list, all containing a different amount of strings. What I would like to see is how many sublists of certain lengths are in this list. Like the following:
Length 2 strings : 70 lists length 3 strings: 45 lists Etcetera.
A logic way to do this (I think) is to make a loop for a length of desire, and then play this loop for all the lengths that I want the amount of lists of.
I would imagine it being something like this:
def countList(lst, x):
count = 0
for i in range(len(lst)):
if x in lst[i]:
count+= 1
return count
x = .....
But I am not sure, because I don't know how to let it count the amount.
If someone could please help me it would be great!!