This is my list and code:
x=[[\"hi hello\"], [\"this is other\"],[\"this\"],[\"something\"],[\"this\"],[\"last element\"]] for line in x: y=x.index(line)
You could use enumerate(...) here.
>>> x=[["hi hello"], ["this is other"],["this"],["something"],["this"],["last element"]] >>> for index, line in enumerate(x): print index, line 0 ['hi hello'] 1 ['this is other'] 2 ['this'] 3 ['something'] 4 ['this'] 5 ['last element']