Day 5Sum of the Even Numbers

    Very easylistsloopsconditions

    Write sum_evens(nums) that returns the sum of the even numbers in nums, skipping the odd ones.

    Examples

    Example 1
    >>> sum_evens([1, 2, 3, 4, 5, 6])
    12
    Example 2
    >>> sum_evens([1, 3, 5])
    0

    Good to know

    • If there are no even numbers (or the list is empty), return 0. Negative even numbers count too.

    Run examples checks the 2 examples above. Submit runs all 6 tests, including hidden edge cases, and marks the challenge solved.

    solution.py
    Loading Python…

    Test results show up here

    Write sum_evens in the editor, then run the examples. Use print() freely: its output is shown for each test.