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 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz