Enter a Python,
Come Out A Dragon

odd_numbers = (num for num in range(10) if num % 2 == 1)

odd_squares = (num ** 2 for num in odd_numbers)

print(‘Sum of squares:’, sum(odd_squares))

print(‘Sum of numbers:’, sum(odd_numbers))

This prints

Sum of squares: 165

Sum of numbers: 0

Why is the sum of numbers zero?

I Know This One

Want to help us solve the newest, biggest problems?

Check out our open positions

Join Us