sum((x for x in xrange(1, 101) if x % 3 == 0 and x % 5 == 0))
Notice the parenthesis instead of square brackets. Your version actually creates a list in memory. A generator generates the items one by one and doesn't need to store them all at the same time.
Can't you all think for a bit? All of These solutions are
O (n) in both time and space... there is solution that will take O (1) time and space - and I think that you learned it in math class at (latest) high school (hint: arithmetic progression)
sum((x for x in xrange(1, 101) if x % 3 == 0 and x % 5 == 0))
Notice the parenthesis instead of square brackets. Your version actually creates a list in memory. A generator generates the items one by one and doesn't need to store them all at the same time.