Script keeps crashing the .blend

hello once again blender people. today my problem is that a script keeps causing the .blend file crash (blender.exe has stopped responding) i don’t usually have this problem but this one won’t go away.

heres the .blend, any help is greatly appreciated :eyebrowlift:
script problem.blend (305 KB)

here is the code that i beleive is crashing it:

import bge
scene = bge.logic.getCurrentScene()
objlist = scene.objects
obj = objlist["master"]
own = bge.logic.getCurrentController().owner

objs = obj[‘objs’]
if own[‘indexemp’] == objs:

What version are you using?
How to use your demo file?
What should happen when?
What is happen when?

-Spacebar to add a link, left shift to set the number of links to Two
-Spacebar should add a link, left shift should remove all of the links except two. and then allow the player to add more links again.
-when I press left shift it removes the links correctly but then it crashes.

This is testing for a specific type of snake-styled game (A math themed snake game)
Most of the logic is run from the object “master” on the first layer.
the script that i believe is crashing it is run from an empty on layer 2.

if you need any more info just ask. I will also see if maybe there is a better way to do the same thing.
also I apologize for the sloppy scripting. I usually simply get it to work and then tidy it up later. :slight_smile: