cleanup and sum over iterator

use isinstance instead of compare type (PEP8)
sum over iterator instead of list
removed trailing whitespace