enumerate
Enumerate — give every item a seat number
- list
- LIST
enumerate is the node that answers "which position is each item at?" It takes a LIST and returns a new LIST of [index, value] pairs - every element gets paired with its position, starting at 0 (or wherever you tell it to start). If you've ever needed to know not just what's in a list but where, this is the tool.
How it works
It's a wrapper around Python's built-in enumerate():
return ([list(enumerate(list, start=start))],)
The optional start input (default 0) lets you number from somewhere other than zero - handy if your list represents "frame 5 through 12" and you want the indices to match real frame numbers instead of offsets.
One thing to be clear about: the output is still a single LIST, and each element of it is a two-item [index, value] pair. So you get [[0, "a"], [1, "b"], [2, "c"]], not a spreadsheet. To pull the index or value out of a pair, you'll go through get item and then further unpacking - there's no magic "first element of the pair" node, you handle the pair like any other value in a list. That's a bit more plumbing than you might expect, but it's also honest about what it's doing.
Where you'd use it
- Order-sensitive processing. When position matters - e.g., "item 2 was the failure, not item 0" - enumerate keeps the index attached to the value so it can't get lost.
- Numbering frames or batch entries with a non-zero start.
- Building a position lookup you can search later with
indexor check withcontains.
Installing
Part of the "Basic data handling" pack by StableLlama. ComfyUI Manager: search "Basic data handling", install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart ComfyUI. Zero dependencies, no models - pure Python, one of the most friction-free installs around.
Gotchas worth knowing
- The output elements are
[index, value]pairs, not flat values - plan for the unpacking. startis the number the first item gets, not an offset you add after;start=2gives[2, ...],[3, ...], etc.- It works on the pack's LIST type (a single Python list variable), not a native data list - the same distinction that runs through the whole pack.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| list | LIST | — | |
| startopt | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LIST | LIST | — |