GIving error self is not defined

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lpyth
    New Member
    • Jul 2008
    • 1

    GIving error self is not defined

    class abc:
    def __init__(self,x ,y,z):
    self.x = x
    self.y = y
    self.z = z



    def add(self):
    c = self.x + self.y + self.z
    print " sum is ",c
    # fib(self,0,1,0)
    print 'hi'


    def fib(self1):
    #self.x = x
    print self1.x
    #self.y = y
    print self1.y
    #self.z = z
    print self1.z
    i = raw_input(" find series till " )
    Self1.z=self1.x +self1.y
    print self1.z
    while self1.z <= i:
    self1.z=self1.x +self1.y
    self1.x=self1.y
    self1.y=self1.z
    print self1.z

    # else:
    # print "Condition fails"


    # def add(self):
    # c = self.x + self.y + self.z
    # print " sum is ", c
    # fib()


    o = abc(10,20,20)
    o.add()
    o1 = abc(0,1,0)
    o1.fib()
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Originally posted by lpyth
    [code=Python]class abc:
    def __init__(self,x ,y,z):
    self.x = x
    self.y = y
    self.z = z



    def add(self):
    c = self.x + self.y + self.z
    print " sum is ",c
    # fib(self,0,1,0)
    print 'hi'


    def fib(self1):
    #self.x = x
    print self1.x
    #self.y = y
    print self1.y
    #self.z = z
    print self1.z
    i = raw_input(" find series till " )
    Self1.z=self1.x +self1.y
    print self1.z
    while self1.z <= i:
    self1.z=self1.x +self1.y
    self1.x=self1.y
    self1.y=self1.z
    print self1.z

    # else:
    # print "Condition fails"


    # def add(self):
    # c = self.x + self.y + self.z
    # print " sum is ", c
    # fib()


    o = abc(10,20,20)
    o.add()
    o1 = abc(0,1,0)
    o1.fib()[/code]
    Please use code tags. It is difficult to follow your code without them.

    Python is case sensitive. Self1 should be self1.

    Comment

    Working...