all problems

Sum of even numbers

pythoneasyfor looplists

Write sum_evens(nums) that returns the sum of all even numbers in the list nums. Return 0 for an empty list.

hint ladder

solution.py
loading editor…
step inspector

Inspect a chained expression (df.query(…).groupby(…).agg(…)) to see the shape and preview after each step.

output

Run your code to see its output, or check your solution to grade it.

Reference solution

The shape we check against. Any implementation that passes the assertions is valid — this one favours clarity.

def sum_evens(nums):
    return sum(n for n in nums if n % 2 == 0)

Code is blurred until you solve this problem — the reasoning stays readable.