# Noob question (list.append after a for loop isn't working)

**URL:** <https://forum.dynamobim.com/t/noob-question-list-append-after-a-for-loop-isnt-working/35041>\
**Category:** Developers\
**Tags:** dynamo\
**Created:** [April 19, 2019, 12:07pm UTC](https://forum.dynamobim.com/t/noob-question-list-append-after-a-for-loop-isnt-working/35041 "2019-04-19T12:07:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ernesto\_Pellegrino](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ernesto_pellegrino/32/105226_2.png) [@Ernesto\_Pellegrino](https://forum.dynamobim.com/u/Ernesto_Pellegrino)\
**Post date:** [April 19, 2019, 12:07pm UTC](https://forum.dynamobim.com/t/noob-question-list-append-after-a-for-loop-isnt-working/35041/1 "2019-04-19T12:07:20Z")

</div>

Hi all, I do not understand why the “.append()” do not work 😕  
When I run the code below, I only get 1 item in the list “list\_Family\_Names”  
Can someone help me to understand why??? O.O  
thanks! 🙂

```
# filtering elements in currentDB
get__All_CommDevices_Elements = FilteredElementCollector(docRevit).OfCategory(BuiltInCategory.OST_CommunicationDevices).WhereElementIsElementType().ToElements()

for el in get__All_CommDevices_Elements:
    element_Family_Name = el.FamilyName
    list_Family_Names = []
list_Family_Names.append(element_Family_Name)

OUT = list_Family_Names
```

---

<div class="post-metadata">

**Author:** ![Tomasz\_Puchala](https://avatars.discourse-cdn.com/v4/letter/t/5f9b8f/32.png) [@Tomasz\_Puchala](https://forum.dynamobim.com/u/Tomasz_Puchala)\
**Post date:** [April 19, 2019, 12:26pm UTC](https://forum.dynamobim.com/t/noob-question-list-append-after-a-for-loop-isnt-working/35041/2 "2019-04-19T12:26:48Z")

</div>

move list\_Family\_Names = outside the loop. Otherwise every iteration you recreate your list over and over again

---

<div class="post-metadata">

**Author:** ![Alban\_de\_Chasteigner](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alban_de_chasteigner/32/39650_2.png) [@Alban\_de\_Chasteigner](https://forum.dynamobim.com/u/Alban_de_Chasteigner)\
**Post date:** [April 19, 2019, 12:28pm UTC](https://forum.dynamobim.com/t/noob-question-list-append-after-a-for-loop-isnt-working/35041/3 "2019-04-19T12:28:49Z")

</div>

And you miss an indent before list\_Family\_Names.append.

```
docRevit = DocumentManager.Instance.CurrentDBDocument
list_Family_Names = []
# filtering elements in currentDB
get__All_CommDevices_Elements = FilteredElementCollector(docRevit).OfCategory(BuiltInCategory.OST_CommunicationDevices).WhereElementIsElementType().ToElements()

for el in get__All_CommDevices_Elements:
	element_Family_Name = el.FamilyName
	list_Family_Names.append(element_Family_Name)

OUT = list_Family_Names
```

---

<div class="post-metadata">

**Author:** ![Ernesto\_Pellegrino](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ernesto_pellegrino/32/105226_2.png) [@Ernesto\_Pellegrino](https://forum.dynamobim.com/u/Ernesto_Pellegrino)\
**Post date:** [April 19, 2019, 1:27pm UTC](https://forum.dynamobim.com/t/noob-question-list-append-after-a-for-loop-isnt-working/35041/4 "2019-04-19T13:27:17Z")

</div>

super easy! 😉 thank you @Tomasz_Puchala & @Alban_de_Chasteigner
