Count Odd and Even Numbers

Write a Python program to count the number of even and odd numbers from array of N numbers. 

# Input the array of N numbers (comma-separated)

numbers = list(map(int, input("Enter N numbers separated by commas: ").split(',')))

# Use list comprehensions to count even and odd numbers

even_count = len([num for num in numbers if num % 2 == 0])

odd_count = len([num for num in numbers if num % 2 != 0])

# Display the counts

print(f"Even numbers: {even_count}")

print(f"Odd numbers: {odd_count}")

 

  

OUTPUT

 

Enter N numbers separated by commas: 45,78,34,22,67,99,55,23

Even numbers: 3

Odd numbers: 5