X1031: Loop Idioms - Find First And Last Index

The following method takes in a ist of integers and a value representing some number appearing in the list, perhaps multiple times.

Using two for loops (one working backwards and one working forwards) and the break keyword, find the first index and last index of value and return the sum of these two indices.

For example if the list was [0, 2, 4, 6, 7, 2, 3] and the value was 2, this method would return 6 (index 1 + index 5).

Your Answer:

Feedback

Your feedback will appear here when you check your answer.