I’m trying to eliminate identical items in the list.
Therefore I try to use the List.UniqueItems node to accomplish that.
But the result is not what I expected, which would be [[1, 2, 3], [1, 2, 3, 4], [2, 3, 4]].
Result is included in the attachment.
# The inputs to this node will be stored as a list in the IN variables.
unique = []
for i in IN[0]:
if i in unique:
continue
else:
unique.append(i)
OUT = unique
Hasn’t been made to work with nested lists, just only checks on the single level.
No problem! You don’t necessarily need to learn Python. I agree that the current List.UniqueItems is not working as you would think it should. Maybe they could add a bool for if they should combine similar lists or not.
I guess another way around would be to make all the lists the same length (by adding a dummy items at the end of each shorter list) so you can compare them with the List.UniqueItems node, but I guess @kennyb6’s method is by far simpler
Edit : also, here is a method (that can largely be improved) if you’re delaing with characters (just a raw idea, it could be enhanced )
You could also insert a separator between each two elements (“%” for instance, or any string), and then String.Split to get back the original items, if you want to deal with multiple digits items. I’ll give it a try later.
Instead of a list.fromsteing node you can get the index of the unique item, and then get the item at index from the prior list. Been awhile but I have executed that workaround awhile back.