It’s not clear to me why this specific task requires a loop:
array = [9, 8, 2, 3, 8, 3, 5]
def remove_2nd_occurance(array, value):
''' Raises ValueError if either of the two values aren't present '''
array.pop(array.index(value, array.index(value) + 1))
remove_2nd_occurance(array, 8)
print(array)