Getting NZEC error in Python 3.5

here is the question -

here is the solution -

I cannot get around as to why I am getting an NZEC error. The code runs on boundary conditions too but still.

Test case:

1 2 3 4 5 6 7 7 6 5 4 3 2 1

This gives runtime error, see:

Traceback (most recent call last):
  File "", line 22, in <module>
  File "", line 12, in check
ValueError: 0 is not in list
1 Like

Hey @shashere_92,

Your code is working fine on the local compiler and also on codechef ide. Instead, your approach to solving the problem is not correct because the output for even sample test case is wrong.

please follow the link
How to solve RAINBOWA or this code in python.

Hope this helps!