How does python get the number of times a sublist appears in a multidimensional list? Instead of the number of times the smallest unit element appears?

as shown in figure

clipboard.png

is there a way to count the number of times article [] appears in article instead of article []? That is, the number of times such a list appears in article. Thank you ~

the original code is as follows:
article = []
sentence0 = [["axiaojiaoyuanb"], [3jue 4]]
sentence1 = [[5djcmfb"], [7pc8]]

article.append (sentence0)
article.append (sentence1)
print (article)
print (article [1])
print (article1)
print (article1 [0])

import collections
import numpy as np
import random
import time

def list_to_dict (lst):

dic = {}
for i in lst:
    dic[i] = lst.count(i)
return dic

def collect (lst):

return dict(collections.Counter(lst))

def unique (lst):

return dict(zip(*np.unique(lst, return_counts=True)))

dict1 = unique (article)
print (dict1)

Mar.15,2021

sentence0 = [['a','b'],[3,4],[1,2,3],[12,3]]
sentence1 = [[5,'b'],[7,8]]

def print_count(l):
    count = 0
    for i in l:
        if isinstance(i, list):
            count += 1
            print_count(i)
    return count


print(print_count(sentence0))     //4
print(print_count(sentence1))     //2
Menu