Why is getEntry() not working?

This is code that detects wether the player is colliding with the floor or not.

        for i in range(self.cHan.getNumEntries()):
            entry = self.cHan.getEntry(i)
            print i
            z = entry.getSurfacePoint(render).getZ()

And obviously self.cHan is collisionHandlerQueue()

now this code works perfectly fine whenever I use for loop.

but if I put an integer to this code,

entry = self.cHan.getEntry(1)

it gives me an error. I thought that getNumEntries() gives you wether 1 or 0. So it should work perfectly fine if I put 0 or 1 to the getEntry()

Does anybody know what the problem is?

Python and C++ both use zero-based indices. So, if there is 1 entry, the entry number to access is 0.

You should never call getEntry before checking getNumEntries() to see if it is there, though. So don’t call getEntry(1) before making sure that getNumEntries() >= 2.

Note that this is a shorter way of doing the snippet you posted:

for entry in self.cHan.getEntries():
    z = entry.getSurfacePoint(render).getZ()

Thanks and congratulation on your 10,000 posts!