Deleting repeated items in a list in code block

IMHO this function should work properly, but it isn’t.
the function should delete repeated items.
Somehow I think, that [Imperative] block doesn’t give the data to a list.
I suppose it could work in Python, but I do still not get in touch with it

Why not just use List.UniqueItems? There are many ways to filter out duplicate items. What is causing you to write a custom function?

Hi @andykandy ,

Could you explain why you need an imperative code block?
Would one of the solutions below also work for you?

Python code, credit to @Vikram_Subbaiah (i think):

from itertools import groupby
OUT = [list(groups) for keyValue,groups in groupby(IN[0])]
1 Like

Thank you! That’s what I was looking for! the problem is solved

if and while loops need to have an Imperative language block, according to DesignScript Syntax.
Surely your all suggestions work excellent! Thaks.

Not me. I’m not snake friendly