# Combine two list of dictionary

**URL:** <https://forum.dynamobim.com/t/combine-two-list-of-dictionary/104300>\
**Category:** Lists-Logic\
**Created:** [September 12, 2024, 2:27pm UTC](https://forum.dynamobim.com/t/combine-two-list-of-dictionary/104300 "2024-09-12T14:27:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dr.hybride](https://avatars.discourse-cdn.com/v4/letter/d/df705f/32.png) [@dr.hybride](https://forum.dynamobim.com/u/dr.hybride)\
**Post date:** [September 12, 2024, 2:27pm UTC](https://forum.dynamobim.com/t/combine-two-list-of-dictionary/104300/1 "2024-09-12T14:27:11Z")

</div>

The two lists contain the same number of dictionaries.  
I would like to add all the keys from each dictionary in list B to list A.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/4/d470712eee13f31f88358a2e60a9e37add32f5c4.png)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [September 12, 2024, 2:56pm UTC](https://forum.dynamobim.com/t/combine-two-list-of-dictionary/104300/2 "2024-09-12T14:56:41Z")

</div>

The most straight forward approach would just be to return a list for keys and values instead of an actual Dictionary A. Then just combine the lists to create Dictionary B. But since you already have both dictionaries, you can just use `Dictionary.SetValueAtKeys` to add new keys.

---

<div class="post-metadata">

**Author:** ![dr.hybride](https://avatars.discourse-cdn.com/v4/letter/d/df705f/32.png) [@dr.hybride](https://forum.dynamobim.com/u/dr.hybride)\
**Post date:** [September 12, 2024, 5:29pm UTC](https://forum.dynamobim.com/t/combine-two-list-of-dictionary/104300/3 "2024-09-12T17:29:34Z")

</div>

thanks for you help but i already try this approach but i failed 🙂

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [September 12, 2024, 5:33pm UTC](https://forum.dynamobim.com/t/combine-two-list-of-dictionary/104300/4 "2024-09-12T17:33:50Z")

</div>

Can you show us what you’ve tried then? If it’s failing, what errors are you getting?

---

<div class="post-metadata">

**Author:** ![dr.hybride](https://avatars.discourse-cdn.com/v4/letter/d/df705f/32.png) [@dr.hybride](https://forum.dynamobim.com/u/dr.hybride)\
**Post date:** [September 12, 2024, 6:07pm UTC](https://forum.dynamobim.com/t/combine-two-list-of-dictionary/104300/5 "2024-09-12T18:07:59Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/c/6c3f3be22c78f915146ba25895355cf89e20c851.png)

It creates another sublist in list 0 Instead of adding it.  
by the way i would like 10 : Angle6 , 11 : EQUIP\_2, 12: Angle3  
and i tied all levels same problem

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [September 12, 2024, 6:19pm UTC](https://forum.dynamobim.com/t/combine-two-list-of-dictionary/104300/6 "2024-09-12T18:19:56Z")

</div>

If you’re going to add the sublist to an existing list then you’ll need to flatten afterwards.

That being said, using `Dictionary.SetValueAtKeys` would be way easier. Just set the list levels to match your dictionaries and combine them.
