Create an empty list and add odd numbers to it.

In this program, we will create an empty list and add odd numbers to it from 1-10.

Steps to solve the program
  1. Create an empty list.
  2. Use for loop to iterate over numbers from 1-10.
  3. During iteration check whether a number is odd or not.
  4. Add those numbers to the empty list.
  5. 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]
				
			

create an empty list and add even numbers from 1-10

print the keys of a dictionary

Leave a Comment