Computer Science, asked by extravalorant123, 3 months ago

WAP to display sum of odd and even values separately from the list of values. 5
For example:
If the VALUES contain [15, 26, 37, 10, 22, 13]
The function should display
Even Sum: 58
Odd Sum: 65

Answers

Answered by Equestriadash
2

The following co‎des have been written using Python.

#obtaining a list for input

l = eval(input("Enter a list of integers: "))

print()

#creating variables for the sum of odd/even integers

os = 0

es = 0

for i in l:

   if i%2 != 0:

       os = os + i

   else:

       es = es + i

#printing the output

print("Even sum: ", es)

print("Odd sum: ", os)

Similar questions