INTERACTIVE ONLINE COURSE

Python 3

FOR BEGINNERS


"The first Python course that simply amazed me. Very well explained and easy to understand." (Alexandru Cosmin)

"The best Python course in Romania." (Iulian Geană)


ALL REVIEWS
SOLVED EXERCISES
PAGE 1 / 4
Python for Loop
Home >>> Online Lessons, Python 3
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:
Editor - for_ex1.py
       
Console / Output done
Review the solved problem,
then proceed to the next page.
 home   list  CONTENTS   perm_identity   arrow_upward