# List.UniqueItems now working as expected... (2.0.0.4354)

**URL:** <https://forum.dynamobim.com/t/list-uniqueitems-now-working-as-expected-2-0-0-4354/25996>\
**Category:** Lists-Logic\
**Tags:** dynamo\
**Created:** [September 17, 2018, 8:19am UTC](https://forum.dynamobim.com/t/list-uniqueitems-now-working-as-expected-2-0-0-4354/25996 "2018-09-17T08:19:45Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ClarKW](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/clarkw/32/55992_2.png) [@ClarKW](https://forum.dynamobim.com/u/ClarKW)\
**Post date:** [September 17, 2018, 8:19am UTC](https://forum.dynamobim.com/t/list-uniqueitems-now-working-as-expected-2-0-0-4354/25996/1 "2018-09-17T08:19:46Z")

</div>

Hi there,

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.

Any suggestion is welcome.  
Thanks a lot.

![UniqueItems](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/f/3ff54ba883354ca67865259f0448ec1b62405eb5.png)

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [September 17, 2018, 8:25am UTC](https://forum.dynamobim.com/t/list-uniqueitems-now-working-as-expected-2-0-0-4354/25996/2 "2018-09-17T08:25:53Z")

</div>

I suppose List.UniqueItems combines list that contains the same items in the same order, even if one has extra items.

 ![uniqueitems](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/e/6e778bb4cf4cd3b68709d984a85e06bac2de71c9.png)

Changing the order does seem to affect it but that isn’t a real work around. You could try to make a python script to get an actual unique items list.

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [September 17, 2018, 8:29am UTC](https://forum.dynamobim.com/t/list-uniqueitems-now-working-as-expected-2-0-0-4354/25996/3 "2018-09-17T08:29:13Z")

</div>

![uniqueitemspython](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/a/1ac4c98ae586821cca59299e3426190be90d5680.png)

Python code:

```
# 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.

---

<div class="post-metadata">

**Author:** ![ClarKW](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/clarkw/32/55992_2.png) [@ClarKW](https://forum.dynamobim.com/u/ClarKW)\
**Post date:** [September 17, 2018, 8:33am UTC](https://forum.dynamobim.com/t/list-uniqueitems-now-working-as-expected-2-0-0-4354/25996/4 "2018-09-17T08:33:10Z")

</div>

Kenny,  
Thank you for the amazingly fast reply! 😃  
So, I guess I need to learn Python… 😆

ClarK

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [September 17, 2018, 8:34am UTC](https://forum.dynamobim.com/t/list-uniqueitems-now-working-as-expected-2-0-0-4354/25996/5 "2018-09-17T08:34:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mellouze](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mellouze](https://forum.dynamobim.com/u/mellouze)\
**Post date:** [September 17, 2018, 8:45am UTC](https://forum.dynamobim.com/t/list-uniqueitems-now-working-as-expected-2-0-0-4354/25996/6 "2018-09-17T08:45:06Z")

</div>

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 🙂 )

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/3/33aff3cf7f26b97a6ba09d1f7f72b09a7158a4a2.png)

---

<div class="post-metadata">

**Author:** ![ClarKW](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/clarkw/32/55992_2.png) [@ClarKW](https://forum.dynamobim.com/u/ClarKW)\
**Post date:** [September 17, 2018, 8:55am UTC](https://forum.dynamobim.com/t/list-uniqueitems-now-working-as-expected-2-0-0-4354/25996/7 "2018-09-17T08:55:16Z")

</div>

@mellouze

Thanks for your idea. 😃  
But in fact I have to deal with 2-digits (and more) numbers.  
I assume this would not be compatible then. 🤔

ClarK

---

<div class="post-metadata">

**Author:** ![mellouze](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mellouze](https://forum.dynamobim.com/u/mellouze)\
**Post date:** [September 17, 2018, 8:58am UTC](https://forum.dynamobim.com/t/list-uniqueitems-now-working-as-expected-2-0-0-4354/25996/8 "2018-09-17T08:58:02Z")

</div>

> [@ClarKW](#):
>
> But in fact I have to deal with 2-digits (and more) numbers.  
> I assume this would not be compatible then. 🤔

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.

---

<div class="post-metadata">

**Author:** ![ClarKW](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/clarkw/32/55992_2.png) [@ClarKW](https://forum.dynamobim.com/u/ClarKW)\
**Post date:** [September 17, 2018, 9:16am UTC](https://forum.dynamobim.com/t/list-uniqueitems-now-working-as-expected-2-0-0-4354/25996/9 "2018-09-17T09:16:04Z")

</div>

@mellouze

Genius!  
It works perfectly! ! 😃 😃

 ![StringSolution](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/2/e267629e9be77ab780ac9a1ba475de6ae8b40c7f.png)

Edited: **String.ToNumber** added

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [September 17, 2018, 9:20am UTC](https://forum.dynamobim.com/t/list-uniqueitems-now-working-as-expected-2-0-0-4354/25996/10 "2018-09-17T09:20:03Z")

</div>

Make sure you convert back to int but other than that, that is a great way to do it OOTB. Nice one @mellouze

---

<div class="post-metadata">

**Author:** ![mellouze](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mellouze](https://forum.dynamobim.com/u/mellouze)\
**Post date:** [September 17, 2018, 9:39am UTC](https://forum.dynamobim.com/t/list-uniqueitems-now-working-as-expected-2-0-0-4354/25996/11 "2018-09-17T09:39:41Z")

</div>

> [@kennyb6](#):
>
> Make sure you convert back to int

Agreed !

> [@ClarKW](#):
>
> It works perfectly! ! 😃 😃

Glad I helped 🙂

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [September 17, 2018, 1:10pm UTC](https://forum.dynamobim.com/t/list-uniqueitems-now-working-as-expected-2-0-0-4354/25996/12 "2018-09-17T13:10:43Z")

</div>

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.
