list=[]
odd_sum=0
even_sum=0
n=int(input("Enter number>>"))
for i in range(n):
num=int(input("Enter element>>".format(i+1)))
list.append(num)
i=0;
while i < len(list):
if list[i] % 2 ==0:
even_sum+=list[i]
else:
odd_sum+=list[i]
i=i+1
print("sum of even",even_sum)
print("sum of odd",odd_sum)
Output:-
Enter number>>3
Enter element>>12
Enter element>>23
Enter element>>34
sum of even 46
sum of odd 23
0 Comments