Write a generator function in python to generate infinite square of numbers using yield


Topic: Write a generator function in python to generate infinite square of numbers using yield

Solution

def nextSquare(): 
    i = 1;  
    # An Infinite loop to generate squares  
    while True: 
        yield i*i                 
        i += 1



List all Python Programs