The Curious Case of the Odd Numbers
Easy+10 XP · +5 Aurabasicsloopsconditional statements
Rohan is studying number theory and is fascinated by odd numbers. He has a list of integers and wants to know how many of them are odd. Can you help him count the odd numbers in his list?
Input
The first line contains an integer N, the number of integers in the list. The second line contains N space-separated integers.
Output
Print a single integer, the count of odd numbers in the list.
Constraints
1 <= N <= 1000. Each integer will be between -1000 and 1000.
Time limit 1 s (native code; slower languages get more)Memory 256 MB15 hidden tests
Example 1
Input
5 1 2 3 4 5
Output
3
The odd numbers are 1, 3, and 5. The count is 3.
Example 2
Input
4 -2 0 4 6
Output
0
There are no odd numbers in the list. The count is 0.
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
Example 1 input
5 1 2 3 4 5
Example 2 input
4 -2 0 4 6