CBSE Class 11 Computer Science
Question 61 of 82
Lists in Python — Question 26
Back to all questions 26
Question WAP that takes an array S as an argument and add all the odd values and display the sum.
S = eval(input("Enter the array: "))
total = 0
for value in S:
if value % 2 != 0:
total += value
print("Sum of odd values:", total)Enter the array: [2, 4, 3, 9, 11, 5, 7, 8]
Sum of odd values: 35