Recursive function returns redundant print statements
Question: I have a simple python application that counts down from 10 to 0. I have it
working except it prints a print message 10 times. Here is my code:

`CountDown.py`:

    
    
    import sys
    
    import counter
    
    
    def main():
        A = counter.counter()
        A.counter(10)
    
    if __name__ == "__main__":
        sys.exit(int(main() or 0))
    

`counter.py`:

    
    
    class counter(object):
    
        def __init__(self):
            pass
            #return super(counter, self).__init__(*args, **kwargs)
            """description of class"""
    
        def counter(self,a):
            if a == 0:
                print ('BlastOff')
            else:
                print ('T equal:', a)
                a -= 1
                self.counter(a)
    
            print ('Exiting from countdown(',a,')')
            return 1
    

This is what I'm receiving at the console window.

    
    
    ('T equal:', 10)
    
    ('T equal:', 9)
    
    ('T equal:', 8)
    
    ('T equal:', 7)
    
    ('T equal:', 6)
    
    ('T equal:', 5)
    
    ('T equal:', 4)
    
    ('T equal:', 3)
    
    ('T equal:', 2)
    
    ('T equal:', 1)
    
    BlastOff
    
    ('Existing from countdown(', 0, ')')
    
    ('Existing from countdown(', 0, ')')
    
    ('Existing from countdown(', 1, ')')
    
    ('Existing from countdown(', 2, ')')
    
    ('Existing from countdown(', 3, ')')
    
    ('Existing from countdown(', 4, ')')
    
    ('Existing from countdown(', 5, ')')
    
    ('Existing from countdown(', 6, ')')
    
    ('Existing from countdown(', 7, ')')
    
    ('Existing from countdown(', 8, ')')
    
    ('Existing from countdown(', 9, ')')
    
    Press any key to continue . . .
    

How do I prevent the multiple `'Existing from countdown'`?


Answer: If you add a `return` statement to the `else:` clause, you will avoid printing
most of the "Exiting" printouts.

    
    
       else:
            print ('T equal:', a)
            a -= 1
            return self.counter(a)
    

