Python Practice › Set Programs › Program 44
Set of odd numbers
Write a Python program to create a set of odd numbers from 1 to 20.
Output
{1, 3, 5, 7, 9, 11, 13, 15, 17, 19}Approach
set(range(1, 21, 2)).
Solution
print(set(range(1, 21, 2)))Output
{1, 3, 5, 7, 9, 11, 13, 15, 17, 19}Learn the concept
New to this topic? Read the lesson, then come back.