2) Take 20 integer inputs from user and print the following:
number of odd numbers
number of even numbers
Answers
Answered by
5
ints = [int(n) for n in input("enter 20 ints: ").split()]
even_ints = [str(n) for n in ints if n % 2 == 0]
odd_ints =[str(n) for n in ints if n % 2 != 0]
print(f"Odd nums: {', '.join(odd_ints)}\nEven nums: {', '.join(even_ints)}")
Similar questions