Problems with Python code

Hi everyone, please see attached files
im working on the development of a program that tells you the maximum area that can be constructed on a terrain according to the city laws. The problem is that im not good at programing on gh python and haven’t been able to get the code to work as it should.

The datta that i have the maximum of squared meters that can be built (some specific number given by the city) and the addition of the area of the several building floors (wich may or may not have the same geometry).

What i need to do is:
if the addition (of the areas of all the floors) without the top floor is bigger than the number that the city laws gives me, delete the top floor and iterate for the new building (the same as before but without the top floor),
else leave the building as it is.

Once the addition off all the remaining floors without the last one of these is smaller than the maximum area given by the city laws i will scale the last floor to reach exactly the maximum constructible area.

i would really appreciate if you could help me with this, thank you
Archivo (34.7 KB)

Obtain a legal copy of Rhino.
Download the Rhino Version 6 Evaluation.
System requirements are here: