When I was searching how to find the index of items in a list, the answer included some code that I couldn't figure out.
Specifically this:
[i for i, j in enumerate(['foo', 'bar', 'baz']) if j == 'bar']
I understood most of it but the 'i for i
' segment has left me confused.
I am very familiar with normal for
loops but I do not understand this, can someone please explain?