Challenge 1: Yield Odd Numbers From 1 to n

Practice your concepts of generators by solving the exercise below.

Problem Statement

Create a generator to yield all the odd numbers from 1 to n.


A number n


All odd numbers from 1 uptil n

Sample Input


Sample Output

1, 3, 5, 7

Coding Exercise

Write your code below. It is recommended​ that you try solving the exercise yourself before viewing the solution.

Get hands-on with 1000+ tech skills courses.