Python2.7 works but Python3.x throws error

def calculate(self):
        normals = []
        for f in self.sides:
            sideN= A(0.0, 0.0, 0.0)
            for i in range(0, len(f)):
                p1 = self.ver[f[(i - 1) % len(f)]]
                p2 = self.ver[f[i]]
                p3 = self.ver[f[(i + 1) % len(f)]]
                v1 = p2 - p1
                v2 = p2 - p3
                v33 = v2.cross(v1)
                v33 = v33.normalize()
                sideN += v33
            sideN = sideN.normalize()
            normals.append(sideN)
        return normals

this runs OK on python 2.7 but when I run in on python 3.8 it throws

 p1 = self.ver[f[(i - 1) % len(f)]]
TypeError: list indices must be integers or slices, not float

when I edit that part;

p1 = self.ver[f[(i - 1) % len(f)]]
p2 = self.ver[f[i]]
p3 = self.ver[f[(i + 1) % len(f)]]

to that

p1 = self.ver[int(f[(i - 1) % len(f)])]
p2 = self.ver[int(f[i])]
p3 = self.ver[int(f[(i + 1) % len(f)])]

then it throws;

p3 = self.ver[int(f[(i + 1) % len(f)])]
IndexError: list index out of range

I tried 2to3 but nothing is changed. What is the problem here?