The simplest way to deal with the 'ZeroDivisionError' in the script would probably be to change
obj.location = sum / n
to
if n > 0:
obj.location = sum / n
Not necessarily the cleanest way, but it works.
Another way to ensure that the delay doesnt get below 1 :
if not empty.get('_RNA_UI'):
empty['_RNA_UI'] = {}
empty['delay'] = 10
empty['_RNA_UI']['delay'] = {
"default": 10,
"min":1,
"max":1000}
Found on https://blender.stackexchange.com/questions/143975/how-to-edit-a-custom-property-in-a-python-script
But it's always good practice to ensure Exceptions like zero division error won't be thrown inside the code since the property can be modified by the user