Count/Highest occurance for unique sublist in a list

I try to count the unique sublist in a list, however I kept getting the error as shown below. Any idea on how to fix this?


Here’s the python code:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

Input=IN[0]
Output = {}

for I in Input:
    for II in I:    
        for lis in I: 
            Output.setdefault(tuple(lis), list()).append(1) 
        for a, b in Output.items(): 
            Output[a] = sum(b)

I was following the tutorial here: https://www.geeksforgeeks.org/python-count-unique-sublists-within-list/

So in my case scenario, I expected an output that saying for L3 list, {“A”,“B”} is the most occurrence sublist, and {“A”,“C”} for the sub-sequence sublist.

Thanks in advance!

You can use List.UniqueItems node :wink:

Hey @lucamanzoni, thanks for the reply!

I was interested in the count too, that means I would like to know that {“A”,“B”} is the most occurrence sublist

I tried something like this, hope is what you need, not sure 100%:

unique = []
count = []

list = IN[0]

for sublist in list:
	for item in sublist:
		if item not in unique:
			unique.append(item)
			
for un in unique:
	for sublist in list:
		n = sublist.count(un)
		if n != 0:
			count.append(n)
	

OUT = unique,count