List and dictionary Comprehensions, how?


I stuck with some basics:
listComprehensions_v1.dyn (8.2 KB)

OUT = [k:[k*i for i in IN[0] for k in IN[1]]

I can`t make “keys”

OUT = {k:len(k) for k in IN[0]}

And can`t count “letters”



Hi @Draxl_Andreas,

If you upgrade to dynamo 2.XX,

The first python script needs some modification:
OUT = {str(k): [k*i for i in IN[0][0]] for k in IN[1][0]}

And the second python script will work:
OUT = {k:len(k) for k in IN[0]}

1 Like

Thanks, i use for learning Python just dynamo studio it is from 2017.
Is there studio like 2020? or can replace the core?


Get the latest Revit Dynamo here
Revit Dynamo

And the latest Dynamo Sandbox here
Dynamo SandBox

As for the Dynamo Studio, I only used it once and that was a long time ago from my previous company so cant answer for sure what to do to upgrade the dynamo core of your Dynamo Studio.

1 Like