需要帮助解决赋值前引用的局部变量“lifespan_x”

zzlelutf  于 2021-08-20  发布在  Java
关注(0)|答案(0)|浏览(150)

我正在课堂上开发一种方法,但我收到了一份 local variable 'lifespan_x' referenced before the assignment 错误。

over={'over_or_under':0,'lifespan':10,'replcost':1000}
under={'over_or_under':1,'lifespan':20,'replcost':2000}

class Segment:
    def age_segment_i_t(self):
        if self.over_or_under==0:
            lifespan_x= over['lifespan']
        if self.over_or_under==1:
            lifespan_x= under['lifespan']
        for t in range (2021,2021+int(lifespan_x)):
            if self.age<=lifespan_x:
                self.age= age_2021+(t-2021)
            elif self.age-lifespan_x==1:
                self.age=1
            elif self.age_i_t-lifespan_x>1:
                self.age= self.age+1
                return(self.age)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题