TypeError: takes exactly 1 argument (2 given) Python Error

后端 未结 1 851
余生分开走
余生分开走 2021-01-24 15:48

The problem is that i have this function:

def fuerza_repulsion(x):
    area = 100 * 100
    k = math.sqrt(area / len(self.grafo[0]))
    return ((k**2 / x) * c2)         


        
1条回答
  •  鱼传尺愫
    2021-01-24 16:39

    It looks like your function is part of a class, in which case the first argument of the function needs to be self, the class object itself. (Also, as @SRC pointed out, you generally call class functions 'methods')

    So therefore use:

    def fuerza_repulsion(self, x):
        area = 100 * 100
        k = math.sqrt(area / len(self.grafo[0]))
        return ((k**2 / x) * c2)
    

    0 讨论(0)
提交回复
热议问题