SOLVED EXERCISES
|
PAGE 1 / 4
|
Python for Loop
REQUIREMENT
Create a program that displays the
sum of odd numbers and
sum of even numbers from a list.
SOLUTION
We use two variables to store the two sums (initially,
0). Then, using
if, we test each element stored in
x
within the
for loop. Analyze and run the program below:
Review the solved problem,
then proceed to the next page.