Get Dictionary Keys
Get Dictionary Keys
Section titled “Get Dictionary Keys”Type: dict-keys · Package: Collections Activities v1.0.3 · Output: List
Gets all the keys of a dictionary as a list. Useful to loop through every entry with a For Each.
How it works
Section titled “How it works”Copies the keys of dict into a new list, in dictionary order. Since it is a copy, you can modify the dictionary (for example, remove keys) while looping through the list without problems.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
dict | Dictionary | — | The dictionary. |
Optional parameters
Section titled “Optional parameters”None.
Output
Section titled “Output”Returns a List (List<object>) with the keys; empty if the dictionary has no entries.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'dict' must be a Dictionary, got …. | dict is not a dictionary (the message shows the type received, or null). |
Example
Section titled “Example”Loop through each pair of the dictionary:
Get Dictionary Keys dict = totalsByCity → output: citiesFor Each items = cities itemVariable = city └─ activities: Get Dictionary Value dict = totalsByCity key = city → output: total Log message = city + ": " + totalRelated activities
Section titled “Related activities”- Get Dictionary Value — read the value of each key.
- Dictionary Count — how many entries there are.