Filter List and Put it back together

Sorry for the long post, but i am sort of stumped. I am going to try to explain this so it makes some semblance of sense…

I am having all sorts of trouble filtering out parts of a list, performing a math equation and combining the list back together. In addition to that, part of math equation is coming from a separate list that will not be in the same order.

Background: I created a script that handles our occupancy schedules. It works fine with the exception of dividing by zero and rounding. It still completes the task, but gives an error. I would prefer to not have the infinity and rounding issues, so i thought i would attempt to filter out the divide by zero portion so it skips it, and then add that data back in at the end. See below for the part of the script that works (simply for reference).

So my though was to use a List.Filter to remove the Occupancy Loads that are 0, then divide then divide the none zeros by the Areas coming from Revit, then stitch things back together. But my first problem was just trying to filter things out and then put them back together without even adding in the calculations. Does anyone have an idea of what might be going wrong here? Ideally, with the portion of the script below i would like to just filter the list and then put it back together in the same order.

In addition to that, i will then need to divide by an Area coming from Revit. That list will be in a different order than the Occupancy Load list due to the filtering.

Maybe it isn’t even possible. Just looking for some guidance to get be pointed back in the right direction b/c i am running into the ceiling of my dynamo knowledge. Thank you!

The rooms with 0 occupancy need to return what value for your final area/occupants? Is it just supposed to be the area as if it were an occupancy of 1? 0? What is the correct value here that would replace infinity?

I think an If statement would be much easier.

OccLoad==0 ? 0 : math

That’s what I was going to suggest, just replacing the 0 values with the area after the function, or replacing all occupancies of 0 with 1 and doing the division to return the full area, but I don’t know what the ending list is being used for, so it may not be viable.

Thank you very much for the replies.

The Occupancy Loads that are zero, will return calculations set up for bowling alleys, fixed seating, booths or arm-less fixed seating. Each of those have calculations that i have created based on their inputs and are added up at the end.

The problem with the suggestion of just replacing with an area is that the parameter is a number, not area. So i would have to replace it with something else either before the calculation or after. I started investigating ways to remove it from the calculations b/c i couldn’t figure out how to put infinity in an if statement.

So if I were to make the zeros become ones before the calculation, they would return just the area being input correct? So then i would create an if statement that says if the area number is being returned to just make it zero. does that sound correct?

Once again thanks for the responses. I think i have something that will work based on your ideas. I am basically going to steal you idea about using an if statement to replace the zero with the area. then when it divides it results in a return of 1. Then i can simply do another if to set it back to zero.

Thanks again