As part of this Kata, you need to find the length of the sequence in an array, between the first and the second occurrence of a specified number.

For example, for a given array `arr`

    [0, -3, 7, 4, 0, 3, 7, 9]
    
Finding length between two `7`s like
    
    lengthOfSequence([0, -3, 7, 4, 0, 3, 7, 9], 7)
    
would return `5`.

For sake of simplicity, there will only be numbers (positive or negative) in the supplied array.

If there are less or more than two occurrences of the number to search for, return `0`, or in Haskell, `Nothing`.

Difficulty: introductory

Starter code:

def length_of_sequence(arr,n):
	

Solutions:
def length_of_sequence(arr, n):
    if arr.count(n) != 2:
        return 0
    a = arr.index(n)
    b = arr.index(n, a + 1)
    return b - a + 1

def length_of_sequence(arr,n):
    return (len(arr) - arr[::-1].index(n) - 1) - arr.index(n) + 1 if arr.count(n) == 2 else 0

def length_of_sequence(arr,n):
    indexes = [i for i,s in enumerate(arr) if s == n]
    if len(indexes) != 2:
        return 0
    else:
        return indexes[-1] - indexes[0] + 1

def length_of_sequence(arr,n):
    pos = [i for i, x in enumerate(arr) if x == n]
    return pos[1] - pos[0] + 1 if len(pos) == 2 else 0

def length_of_sequence(arr, n):
    try:
        i = arr.index(n)
        j = arr.index(n, i+1)
        try:
            arr.index(n, j+1)
            return 0
        except ValueError:
            return j - i + 1
    except ValueError:
        return 0

def length_of_sequence(arr,n):
    indexes = [i for i, x in enumerate(arr) if x == n]
    if len(indexes) != 2:
        return 0
    return indexes[1] - indexes[0] + 1

def length_of_sequence(arr,n):
    if arr.count(n) != 2:
        return 0
    else:
        return arr.index(n, arr.index(n)+1) - arr.index(n) + 1


def length_of_sequence(arr, n):
  inds = [i for i, v in enumerate(arr) if v == n]
  return inds[1] - inds[0] + 1 if len(inds) == 2 else 0

def length_of_sequence(arr,n):
    #your code here
    if arr.count(n) != 2:
        return 0
    return (arr[arr.index(n)+1:].index(n) + 2)


def length_of_sequence(arr,n):
    if arr.count(n) != 2:
        return 0
    
    left = arr.index(n)
    right = arr.index(n, left + 1)
    return right - left + 1