Set 103 Practical Question

⭐ Q3. Lambda Function से Even और Odd संख्या गिनना

Example Code (Read Only):


list1 = [10, 21, 4, 45, 66, 93, 11]

odd_count = len(list(filter(lambda x: (x % 2 != 0), list1)))
even_count = len(list(filter(lambda x: (x % 2 == 0), list1)))

print("Even numbers:", even_count)
print("Odd numbers:", odd_count)

Python Online Editor