really unsure as to why the enumeration command isn't creating a list of items here? https://www.codewars.com/kata/5566b0dd450172dfc4000005/train/python
My Code:
def length_of_sequence(arr,n):
index = [i for i, e in enumerate(arr) if e == n ]
print(index)
return arr[(index.pop(0)):(index.pop(-1))]
Test:
@test.describe("Fixed Tests")
def fixed_tests():
@test.it('Basic Test Cases')
def basic_test_cases():
test.assert_equals(length_of_sequence([1], 0), 0, 'Returns zero when the element is not found in the array')
test.assert_equals(length_of_sequence([1], 1), 0, 'Returns zero with only one element in the array')
test.assert_equals(length_of_sequence([1, 1], 1), 2, 'Returns two when there are only two elements in the array');
test.assert_equals(length_of_sequence([1, 2, 3, 1], 1), 4, 'Returns four for an array of length four and the number to be searched at the boundaries');
test.assert_equals(length_of_sequence([-7, 5, 0, 2, 9, 5], 5), 5, 'Returns five');
test.assert_equals(length_of_sequence([-7, 6, 2, -7, 4], -7), 4, 'Returns four');
test.assert_equals(length_of_sequence([0, 8, -7, 6, 1, 2, -7, 4, 8, 9], 8), 8, 'Returns eight')
test.assert_equals(length_of_sequence([-7, 3, -7, -7, 2, 1], -7), 0, 'Returns zero as when there are more than two instances')
test.assert_equals(length_of_sequence([-7, 3, -7, -7, 2, -7], -7), 0, 'Returns zero as when there are more than two instances')