# Preventing a list consisting of null values

**URL:** <https://forum.dynamobim.com/t/preventing-a-list-consisting-of-null-values/16579>\
**Category:** Lists-Logic\
**Tags:** excel, python, dynamo\
**Created:** [November 17, 2017, 8:35am UTC](https://forum.dynamobim.com/t/preventing-a-list-consisting-of-null-values/16579 "2017-11-17T08:35:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Claus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/claus/32/37199_2.png) [@Claus](https://forum.dynamobim.com/u/Claus)\
**Post date:** [November 17, 2017, 8:35am UTC](https://forum.dynamobim.com/t/preventing-a-list-consisting-of-null-values/16579/1 "2017-11-17T08:35:58Z")

</div>

As shown in the image below (image A) I tried three different methods to filter out null values from a list while preserving the order. The aim is to write these lists to Excel later on. The parameter I’m interested is ‘Phasing Demolished’. When some walls have a different value for Phasing Demolished the script works. Despite getting some errors.

Now the problem is when Phasing Demolished is all set to None for every wall in this project, the script returns empty lists because all values are null. I want to use these lists later on to create and transpose lists for writing to Excel. This does not work with empty lists.

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

Is there some way to preserve list length with a list of all null values? I was thinking on trying to filter the list with an if-statement before it takes a Parameter.Name value. But I can’t seem to get it to work. Thanks in advance.

---

<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:** [November 17, 2017, 1:19pm UTC](https://forum.dynamobim.com/t/preventing-a-list-consisting-of-null-values/16579/2 "2017-11-17T13:19:43Z")

</div>

I would go with the Python option, Method 1. The only problem is getting the phase name, which you can add to your Python code.

Instead of

```
else:
     output.append(i)

```

use

```
else:
     output.append(i.Name)
```

---

<div class="post-metadata">

**Author:** ![Claus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/claus/32/37199_2.png) [@Claus](https://forum.dynamobim.com/u/Claus)\
**Post date:** [November 17, 2017, 1:30pm UTC](https://forum.dynamobim.com/t/preventing-a-list-consisting-of-null-values/16579/3 "2017-11-17T13:30:29Z")

</div>

Thank you very much!, that solution was really easy. 😀 I did not know you could acces element names in Python. I was thinking too difficult. It is exactly what I needed.

---

<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:** [November 17, 2017, 1:39pm UTC](https://forum.dynamobim.com/t/preventing-a-list-consisting-of-null-values/16579/4 "2017-11-17T13:39:46Z")

</div>

You have access to (almost) the entire API. There’s a lot you can do.
