- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Python program to find the sum of all even and odd digits of an integer list

When it is required to find the sum of all even and odd digits of an integer list, a simple iteration and the ‘modulus’ operator are used.

Below is a demonstration of the same −

## Example

my_list = [369, 793, 2848, 4314, 57467] print("The list is :") print(my_list) sum_odd = 0 sum_even = 0 for index in my_list: for element in str(index): if int(element) % 2 == 0: sum_even += int(element) else: sum_odd += int(element) print("The result is :") print("The sum of odd digits is :") print(sum_odd) print("The sum of odd digits is :") print(sum_even)

## Output

The list is : [369, 793, 2848, 4314, 57467] The result is : The sum of odd digits is : 54 The sum of odd digits is : 46

## Explanation

A list of integers is defined and is displayed on the console.

Two variables ‘sum_odd’ and ‘sum_even’ are declared.

The list is iterated over, and the sum of odd digits and even digits are calculated.

This is done by getting the modulus of the element with 2, and comparing it with 0.

This is the output that is displayed on the console.

- Related Questions & Answers
- Count even and odd digits in an Integer in C++
- Find the sum of digits of a number at even and odd places in C++
- Python Program for Difference between sums of odd and even digits
- Program to find the sum of all digits of given number in Python
- Program to find sum of all odd length subarrays in Python
- Program to find sum of odd elements from list in Python
- Find sum of even and odd nodes in a linked list in C++
- Difference between sums of odd and even digits.
- C Program for the Difference between sums of odd and even digits?
- C Program for Difference between sums of odd and even digits?
- Subtract the Product and Sum of Digits of an Integer in C++
- Sum of individual even and odd digits in a string number using JavaScript
- Program to find nearest number of n where all digits are odd in python
- Find the Number With Even Sum of Digits using C++
- Program to find minimum digits sum of deleted digits in Python

Advertisements