By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
 464,562 Members | 953 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,562 IT Pros & Developers. It's quick & easy.

# GIving error self is not defined

 P: 1 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() Jul 28 '08 #1
Share this Question
1 Reply

 Expert Mod 2.5K+ P: 2,851 Expand|Select|Wrap|Line Numbers 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() Please use code tags. It is difficult to follow your code without them. Python is case sensitive. Self1 should be self1. Jul 28 '08 #2

### Post your reply

Sign in to post your reply or Sign up for a free account.