Advertisement
Guest User

Total off Odd/Even numbers

a guest
Jun 27th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.22 KB | None | 0 0
  1. x = [23, 76, 89, 91, 108]
  2.  
  3. odd_total = 0
  4. even_total = 0
  5.  
  6. for i in x:
  7.     if i % 2:
  8.         odd_total += i
  9.     else:
  10.         even_total += i
  11.  
  12. print "Total of even numbers: %s" % even_total
  13. print "Total of odd numbers: %s" % odd_total
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement