Please write a function using generator to print the even numbers between 0 and n in comma separated form while n is input by console.


Topic: Please write a function using generator to print the even numbers between 0 and n in comma separated form while n is input by console.

Solution

def EvenGenerator(n):
    i=0
    while i<=n:
        if i%2==0:
            yield i
        i+=1



List all Python Programs