Instruction
Excellent! Let's do one more exercise with index().
Exercise
Write a function named find_average_first_index(input_list, input_letter) that accepts a list of strings and a single letter.
- The function should return the average index of the first occurrence of the
input_letteramong all strings in the list that contains theinput_letter. - If a list element does not contain the given letter, skip it. Do not add it to the number of elements when calculating the average.
- If no list element contains the given letter, return
-1.
Example: for the sample_list in the template code and the input letter 'o', the function should return 6.33:
'Black Mirror':'o'at index10'Breaking Bad': no letter'o'(ignored)'Stranger Things': no letter'o'(ignored)'The Leftovers':'o'at index8'How I Met Your Mother':'o'at index1
(10 + 8 + 1) / 3 = 6.33
Stuck? Here's a hint!
Create two temporary variables, sum_indexes and counter. Iterate over the list and use a try-except block with index().



