Sunday, March 04, 2018

Python : Find Index of Matching Element in List

Something simple, like

l = ['a', 'b', 'c']

i_c = l.index( 'c' )

Shame that codecademy doesn't tell you you can use [-2:] to retrieve the last two elements..

No comments: