I am going to show the exercise that I am trying to replicate in Dynamo but with a screenshot from Excel.
As you can see below, I have a column that shows TRUE or FALSE. FALSE is always gonna be “0” but I would like to achieve that when it starts the list, all first consecutive TRUE values are going to be “1”. Then, if a FALSE is in between and the TRUE values appear again, those TRUE values shall be “2” instead of “1”.
for i in True_False:
if i == False:
out.append(0)
state = False
elif i == True:
Trues +=1
if state == False:
if Trues !=1 :
count +=1
state = True
out.append(count)
I tried to create the node in Dynamo but I had to flatten the sublists in order to have the same structure as you have. Despite flattening the sublists, I am getting an Empty list outcome from the Python node:
Now it is working fine. As you can see in the screenshot highlighted in red, my input is a string so I had to write in the Python node the “true” and “false” between quotes.
Then, I highlighted in green how my input is. You will notice that I have several levels (sublists) instead of a flattened list (highlighted in green).
First of all, thank you so much for your supoprt. I did not see that you posted.
Please find a screenshot with a sample of how the script should work. You will notice that it must work with sublists and it increases the values within a sublist and then it starts again for the next sublist.