CBSE Class 11 Informatics Practices
Question 61 of 80
Lists in Python — Question 24
Back to all questions 24
Question Write a program that accepts elements of a list S and adds all the odd values and displays the sum.
S = eval(input("Enter list: "))
sum_odd = 0
for num in S:
if num % 2 != 0:
sum_odd += num
print("The sum of all odd values in the list is: ", sum_odd)Enter list: [43, 23, 5, 6, 8, 10, 12]
The sum of all odd values in the list is: 71