Question:
Write a python script to display elements of list and also count and print total even elements in the list.
n=[1,12,33,14,25,16,47,98] e=0 for i in n: print(i) if i%2==0: e=e+1 print("Total even elements = ",e)
Output:
1
12
33
14
25
16
47
98
Total even elements = 4
Question:
Write a python script to display elements of list and also count and print total odd elements in the list.
n=[1,12,33,14,25,16,47,98] e=0 for i in n: print(i) if i%2==1: #if i%2!=0 e=e+1 print("Total odd elements = ",e)
Output:
1
12
33
14
25
16
47
98
Total odd elements = 4