Python List Indices

I needed to delete this code from a notebook, because it wasn’t doing anything, but the code was useful enough to keep:

shorts = [ texts.index(text) for text in texts if len(text) < 500 ]

Leave a Reply