Write a Python program to print the numbers of a specified list after removing even numbers from it


This program creates a list called "n" that contains integers 7, 32, 81, 20, 25, 14, 23, and 27. Then, it creates a new list called "n" that only contains the elements from the original list that are odd numbers (i.e. not divisible by 2) using a list comprehension. The list comprehension iterates over each element "x" in the original list "n" and only includes "x" in the new list if "x" is not divisible by 2 (x%2!=0). The final printed list contains 7, 81, 25, 23, and 27.

Source Code

n = [7,32,81,20,25,14,23,27]
n = [x for x in n if x%2!=0]
print(n)
 

Output

[7, 81, 25, 23, 27]

Example Programs