How to find odd numbers in python?

1. By using filter() method
a=[1,2,3,4,5,6,7,8,9,10]
odd=filter(lambda x:x%2!=0, a)
print (list(odd))
#Output:[1, 3, 5, 7, 9]

2.By using list comprehension

a=[1,2,3,4,5,6,7,8,9,10]
odd=[x for x in a if x%2!=0]
print (odd)
#Output:[1, 3, 5, 7, 9]

One-Time
Monthly
Yearly

Make a one-time donation

Make a monthly donation

Make a yearly donation

Choose an amount

¤5.00
¤15.00
¤100.00
¤5.00
¤15.00
¤100.00
¤5.00
¤15.00
¤100.00

Or enter a custom amount

¤

Your contribution is appreciated.

Your contribution is appreciated.

Your contribution is appreciated.

Buy Me a CoffeeBuy Me a CoffeeBuy Me a Coffee

2 comments

Leave a reply to Indhumathy Chelliah Cancel reply