In this Python program, we will learn how to find the sum of even and odd numbers in a given list.

Here is the source code of the program to find the sum of the even and odd numbers in a given list.

```
# Python Program to find the Sum of Even and Odd Numbers in a Given List
# Using For Loop with Range
Even_Sum = 0
Odd_Sum = 0
num_list = [18, 58, 66, 85, 25, 51]
# Print the Original List
print("Original List: ", num_list)
for j in range(len(num_list)):
if(num_list[j] % 2 == 0):
Even_Sum = Even_Sum + num_list[j]
else:
Odd_Sum = Odd_Sum + num_list[j]
print("\nThe Sum of Even Numbers in the Given List = ", Even_Sum)
print("The Sum of Odd Numbers in the Given List = ", Odd_Sum)
```

Original List: [18, 58, 66, 85, 25, 51]

The Sum of Even Numbers in the Given List = 142

The Sum of Odd Numbers in the Given List = 161

```
# Python Program to find the Sum of Even and Odd Numbers in a Given List Using While Loop
Even_Sum = 0
Odd_Sum = 0
j = 0
num_list = [18, 58, 66, 85, 25, 51]
# Print the Original List
print("Original List: ", num_list)
while(j < len(num_list)):
if(num_list[j] % 2 == 0):
Even_Sum = Even_Sum + num_list[j]
else:
Odd_Sum = Odd_Sum + num_list[j]
j = j+ 1
print("\nThe Sum of Even Numbers in the Given List = ", Even_Sum)
print("The Sum of Odd Numbers in the Given List = ", Odd_Sum)
```

Original List: [18, 58, 66, 85, 25, 51]

The Sum of Even Numbers in the Given List = 142

The Sum of Odd Numbers in the Given List = 161

## Comments