Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.

Add some print statements to determine the actual values of the index and the...