enumerate
Numbering a set — and why that's trickier than it sounds
- set
- LIST
enumerate takes a SET and returns a LIST of (index, value) tuples, so you can pair every element in the set with a number starting at 0 (or wherever you tell it to start). If you've done any Python, this is enumerate() - the function that walks a collection while keeping count - exposed as a node.
Why bother in a ComfyUI workflow? Sets are the tool you use for "pool of unique values," but they don't have positions. Enumerate is how you bolt numbers onto that pool when you need one: assign an ID to every tag in a curated set, number the distinct frames you're keeping, or build a lookup table where each unique value gets a sequential key. The output is a LIST, so it plugs into the pack's LIST nodes - get item, slice, and so on - for index-based access.
How it works
The mechanism is literally list(enumerate(set, start=start)). For each element it produces a tuple (index, value), where the index counts up from the start parameter (default 0), and it wraps the whole thing in a LIST as a single variable.
Here's the honest caveat, and the node's own docs say it plainly: sets are unordered, so the enumeration order is arbitrary. Which element gets index 0 is not something you control. The order is consistent within a single run - the same set enumerates the same way on every pass - but it's not the order you typed things in, and it can differ between sets that happen to hold the same values.
Inputs and output
set(SET) - the set to enumerate.start(INT, optional, default0) - the number the first index starts at. Handy if you want 1-based numbering.- LIST (output) - a list of
(index, value)tuples.
Installing
It's in Basic data handling by StableLlama. Install through ComfyUI Manager - search "Basic data handling" - or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart ComfyUI after either route. No dependencies and no models to fetch, which is typical for this pack and makes it a painless install.
Common issues
If your indices don't line up with what you expected, the answer is almost always the ordering caveat - the set chose its own order, not yours. If the assignment of numbers to values actually matters for output (like assigning prompt slots), sort the set first via convert to LIST and the pack's sort node, then enumerate that. And if you want stable IDs across multiple runs, remember "consistent within a single operation" - rebuild the set the same way each run and you'll get the same enumeration, but don't count on it surviving changes upstream.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| set | SET | — | |
| startopt | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LIST | LIST | — |