我正在尝试从 mathsum 方法调用init方法中列出的任何函数,但不断收到如下错误:
“XXX”对象没有“操作员”属性。
class Math(object):
"Main class to generate different math sums based on operator and difficulty levels"
def __init__(self):
self.operator = [
addition,
subtraction,
multiplication,
division
])
def addition(self, a, b): return ('addition', '+', a+b)
def subtraction(self, a, b): return ('subtraction', '-', a-c)
def mutliplication(self, a, b): return ('multiplication', '*', a*c)
def division(self, a, b): return ('division', '/', a/c)
def mathsum(self, difficulty):
"""Function that generates random operator and math sum checks against your answer"""
print self.operator
请帮忙