In this program, we will create an empty list and add odd numbers to it from 1-10.
Steps to solve the program
- Create an empty list.
- Use for loop to iterate over numbers from 1-10.
- During iteration check whether a number is odd or not.
- Add those numbers to the empty list.
- Print the output.
odd = []
for i in range(1,11):
if i%2 != 0:
odd.append(i)
print(odd)
Output :
[1, 3, 5, 7, 9]