Answer to Question #229959 in Python for Assignment

Question #229959
Write a python program that takes 10 inputs from the user, and then prints how many inputs are odd and how many inputs are even. Use for loop.

Sample input:

2

6

8

3

9

2

6

4

3

7

Sample Output:

Even numbers = 6, Odd numbers = 4
1
Expert's answer
2021-08-28T06:09:25-0400
list1 = []
list2 = []
for i in range(10):
  n = int(input('Enter number here: '))
  if n % 2 == 0:
    list1.append(n)
  else:
    list2.append(n)
  
print('Even numbers = {}, odd numbers = {}'.format(len(list1), len(list2)))

Enter number here: 2
Enter number here: 6
Enter number here: 8
Enter number here: 3
Enter number here: 9
Enter number here: 2
Enter number here: 6
Enter number here: 4
Enter number here: 3
Enter number here: 7
Even numbers = 6, odd numbers = 4

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS