How to get Dictionary Input List for multiple Values?

Hi,

.

I’m trying to set a Dictionary List in Python,

that I can get the Values when I give Numbers for Key.

but I can only set one Key at a time for IN[3].

how can I use a list of Numbers to get each Values at the same time?

.

Below is the screenshot and the .dyn / Python Script

Thanks!

.

PythonDictTest1.dyn (3.8 KB)

.


import clr

listInput = IN[0]
valueThickness = IN[1]
valueOffset = IN[2]
x = IN[3]

index1 = listInput.index(x)
key1 = {}
key1[listInput[index1]] = [valueThickness[index1], valueOffset[index1]]

listOutput1 = [key1[listInput[index1]]]

OUT = listOutput1

Hi,

Have a look at the “Dictionary.ByKeysValues” node from spring nodes:

1 Like

Alternatively, you can make a named Dynamo list. The only limitation is it works only with strings for the keys and not any other immutable objects.

4 Likes

Thanks, both ways are great help to me,

I don’t know much about coding in Python,

not to mention using Dynamo for scripting…

.

Your SpringNodes package really is a good source for learning Python in Dynamo!

and It’s really helpful!
.

Thank you so much!!