end cube with distance in python

How would i end a cube when the player reaches a certain distance with python?

if obj.getDistanceTo(player) > 5:

I figured how to make the code work.I had not defined the player so i looked on youtube for what to do.And it now works.Want to see it?I used the template that is in blender.