
Reet C. answered 04/09/19
Computer Engineer With A Passion For Teaching!
You can use the built-in enumerate function:
This function yields the index and the item in the list to the two variables in the for loop. This also is only linear in complexity whereas the answer utilizing the index() function would be quadratic time.
Hope that helps :)