Programming Examples

Python program to create a list of numbers in the range 1 to 10 Then delete all the even numbers from the list and print the final list


Write a program to create a list of numbers in the range 1 to 10. Then delete all the even numbers from the list and print the final list.

Solution

Num = []
for x in range(1,11):
	Num.append(x)
print("The list of numbers from 1 to 10 = ", Num)
for index, i in enumerate(Num):
	if(i%2==0):
		del Num[index]
print("The list after deleting even numbers = ", Num)
Output

The list of numbers from 1 to 10 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

The list after deleting even numbers = [1, 3, 5, 7, 9]

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad