Program - custom counter function


Topic: Program - custom counter function

Solution

def custom_counter():
    """
    An implementation of closures
    """
    x = 0
    def inner():
       nonlocal x
       x += 1
       print(f' Switch or button is called {x} times')
     return inner



List all Python Programs