Getting error as Unbound Local Error in UNQ_C3 after Testing

The output is correct as expected one and even after that getting error.
how to resolve this issue?

The problem may be that if len(y) is zero, then your line 21 is skipped, and execution arrives at line 22 without useful values for p1.

but it is saying that “Unbound error: local variable ‘p1’ referenced before assignment” and the output coming as expected.

Yes, that’s exactly the problem. You don’t have any code that gives p1 a value when len(y) is zero.