Filter and flatten nested list of lists preserving indices

I have a nested list of lists which shows rooms and which floors are inside them. However I can’t seem to work out how to convert that list so that it only shows floors whilst preserving the indices (images below should explain more):

This demonstrates the intended purpose/workflow thereafter:

like this?

however, feeding an empty list will give an error.

Hi erfajo, cheers for the input. As you highlighted the index method fails when trying to preserve null fields:

then try this… however, you need to do something with the empty list, since that index will be removed…


or maybe like this

1 Like

Yes, I reckon this should get me there provided I can use the ‘empty’ entries in the original list as a Boolean mask on the list of all rooms. That way the indices for my rooms and floors will match up. Cheers

Left the office now, will have to try it out later.