类的Python代码未返回值

类的Python代码未返回值,python,python-3.x,Python,Python 3.x,您好,我有一个python代码,它不断给我一个错误。在我继续之前,有人可以看一下它。这是我的python类用来计算手机账单金额的。我现在有了这个,但它没有返回值 经济计划包括30美元的无限语音和文本,10美元1 GB的数据,每GB超过6美元 class cellphone: cost = 30 due = 0 amountGB = 0 Total = 0 def econPlan (self, gB, gbOver): self.cost

您好,我有一个python代码,它不断给我一个错误。在我继续之前,有人可以看一下它。这是我的python类用来计算手机账单金额的。我现在有了这个,但它没有返回值

经济计划包括30美元的无限语音和文本,10美元1 GB的数据,每GB超过6美元

class cellphone:
    cost = 30
    due = 0
    amountGB = 0
    Total = 0

    def econPlan (self, gB, gbOver):
        self.cost = 30
        self.gB = 1
        self.gbOver = 6
        self.due = 0

        while amountGB >= self.gB:
            int(amountGB - self.gB)* self.gbOver
        return self.due

        while cPlan == Econ and amountGB >= self.gB:
            print ("$",self.due)

    def normPlan (self, gB, gbOver):
        self.cost = 30
        self.gB = 5
        self.gbOver = 4

        while amountGB >= self.gB:
            int(amountGB - self.gB)* self.gbOver
        return self.due

        while cPlan == Norm and amountGB >= self.gB:
            print ("$",self.due)






print (" Which Plan do you have: econ or norm?")
print (" Econ is $30 unlimited voice and text, 1 GB data for $10, and $6 for every GB over.")
print (" Norm is $30 unlimited voice and text, 5 GB data for $30, and $4 for every GB over.")

econ = cellphone.econPlan
norm = cellphone.normPlan
cellphone.cPlan = input ("So which plan do you have? >>")
if cellphone.cPlan == econ:
    print ("you have the Economy plan")

elif cellphone.cPlan == norm:
    print ("you have the Normal plan")

cellphone.amountGB = input ("how many GB did you used >>")
if cellphone.cPlan == "Econ":
    print (cellphone.due)
正常的计划包括30美元的语音和文本不受限制,30美元5 GB的数据,每GB超过4美元

class cellphone:
    cost = 30
    due = 0
    amountGB = 0
    Total = 0

    def econPlan (self, gB, gbOver):
        self.cost = 30
        self.gB = 1
        self.gbOver = 6
        self.due = 0

        while amountGB >= self.gB:
            int(amountGB - self.gB)* self.gbOver
        return self.due

        while cPlan == Econ and amountGB >= self.gB:
            print ("$",self.due)

    def normPlan (self, gB, gbOver):
        self.cost = 30
        self.gB = 5
        self.gbOver = 4

        while amountGB >= self.gB:
            int(amountGB - self.gB)* self.gbOver
        return self.due

        while cPlan == Norm and amountGB >= self.gB:
            print ("$",self.due)






print (" Which Plan do you have: econ or norm?")
print (" Econ is $30 unlimited voice and text, 1 GB data for $10, and $6 for every GB over.")
print (" Norm is $30 unlimited voice and text, 5 GB data for $30, and $4 for every GB over.")

econ = cellphone.econPlan
norm = cellphone.normPlan
cellphone.cPlan = input ("So which plan do you have? >>")
if cellphone.cPlan == econ:
    print ("you have the Economy plan")

elif cellphone.cPlan == norm:
    print ("you have the Normal plan")

cellphone.amountGB = input ("how many GB did you used >>")
if cellphone.cPlan == "Econ":
    print (cellphone.due)

Self只存在于方法中。如果要获取方法中某个变量的当前值,请调用该方法并返回该变量

发布错误…错误是什么?其中的
self
?是self-required如果类方法中的块没有正确的缩进。