Picks Texts from a List by Index
Grab one item out of a list, with negative indices and a wrap counter
- list_item
- size
- wraps
Picks Texts from a List by Index is a tiny indexing utility: you give it a list of strings and an integer, it gives you back the string at that position. It's the natural sequel to the pack's polymath_TextSplitter - split a prompt dump into lines, then pick line 3 and wire it into whatever needs just one prompt. Simple, but it has a couple of behaviors worth knowing before you rely on it.
The inputs
- list_input - a STRING list, force-input (must come from another node's list output). Plug the
splitted_textsoutput of polymath_TextSplitter in here, or any other node that emits a list of strings. - index - an integer from -999 to 999, default 0. This is where it gets interesting: negative indices count from the end. Index
-1gives you the last item,-2the second-to-last, and so on. If you're processing a batch of prompts and want "the last one," you don't need to know how many there are.
The outputs
Three, and they make this more than a dumb picker:
- list_item - the string at
index. This is the one you wire onward into a text encode, a chat node, or a display. - size - the length of the input list. Handy when you want to know how many items a batch produced.
- wraps - how many times the index wrapped around the list. Because the node doesn't error on out-of-bounds indices: it wraps. Index 5 on a 3-item list gives you item 2 and reports
wraps = 1. If you're looping through a list and need to know when you've gone around once, that's the signal to stop or switch behavior.
Under the hood it's a modular-index function - index % length, with negative indices mapped into the positive range - so no exceptions, ever. That's friendlier than a hard error for automation, but it's also the kind of silent forgiveness that hides bugs: a typo that gives you index 20 on a 3-item list won't crash your workflow, it'll just quietly give you the wrong prompt. If that happens, the wraps output is your debugging hint.
Installation
Comes with the comfyui_LLM_Polymath pack. ComfyUI Manager → search "comfyui_LLM_Polymath" → install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/lum3on/comfyui_LLM_Polymath
pip install -r requirements.txt
then restart ComfyUI. This node is pure list math - it needs nothing from the pack's heavy dependency list - so it'll load even if easyocr or gallery-dl failed on your machine.
When you'd actually use it
Batch workflows, mostly. Split a big set of candidate prompts into a list, and instead of building one chat node per prompt, use a single chat node and drive this picker's index from a counter node to walk through them one at a time. The size output tells you when you're done, and wraps tells you when you've circled back. It's a small node with exactly one job - but in ComfyUI, the small nodes are the ones you end up building your own workflows out of.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| list_input | STRING | — | |
| index | INT | 0-999–999 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| list_item | STRING | — |
| size | INT | — |
| wraps | INT | — |