Chef Aliens - getting NZEC Error

I tried solving the Chef Aliens problem (using Python) but encountered a NZEC error when I submitted it . The program is working fine on the compiler I use. Since, it’s the first time I am getting this error, I have no idea as to where in the program I have gone wrong. Please help so that I can avoid such mistakes in the future.
Here is my code :