Sorry mate, you don’t have to use python, maybe it was an overkill. Here is the solution with just dynamo: