Fibonacci series not printing right output

Fibonacci series not printing right output
0.0 0

#1

Hello everyone . I was getting my hands on Python to learn Data structures and algorithms in python. I tried to implement progression class with sub classes : AP , GP and fibonacci… the implementation of AP and GP works well but fibonacci doesnt work right. Here is the code:

class progression:
    def __init__(self,start):
        self.start = start
        self.x = str()
        self.answer = int()
    def __next__(self):
        self.answer = self.start
        self.start += 1
        return self.answer
    def __iter__(self):
        return self

    def printer(self,n):
        for i in range(0,n):
            self.x = self.x + ' ' + ''.join(str(next(self)))

        print(self.x)

class arithematic(progression):
    def __init__(self,start,inc):
        super().__init__(start)
        self.inc = inc

    def __next__(self):
        self.answer = self.start
        self.start += self.inc
        return self.answer

class gp(progression):
    def __init__(self,start,factor):
        super().__init__(start)
        self.factor = factor

    def __next__(self):
        self.answer = self.start
        self.start *= self.factor
        return self.answer

class fibo(progression):
    def __init__(self,first,second):
        super().__init__(first)
        self.prev = second - first

    def next(self):
        self.answer = self.start
        self.start += self.prev
        self.prev = self.answer
        return self.answer



obj = fibo(1,3)
obj.printer(10)

Help me debug the program please! i cannot seem to find the error


#2

143/5000
In the class fibo you are declaring a method next(self) and not the magic method __next__(self) which is the method invoked by printer ()

Just correct and go!

def  __next__ (self):
        self.answer = self.start
        self.start += self.prev
        self.prev = self.answer
        return self.answer