as shown in figure
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)