C.py - SUMDIV
Your task is to write a function sum_divisible_by_7(nums)
that calculates the sum of all numbers in a given list nums
that are divisible by 7. Return the sum of those numbers.
Input:A list of integers nums
.
Output:Return the sum of all numbers in the list that are divisible by 7.
Example 1:
Input: nums = [7, 14, 20, 21, 28]
Return: 70
Explanation: 7 + 14 + 21 + 28 = 70
Example 2:
Input: nums = [1, 2, 3, 4, 5, 6]
Return: 0
Explanation: None of the numbers in the list are divisible by 7, so the sum is 0.
Example 3:
Input: nums = [7, 15, 35, 49, 50]
Return: 91
Explanation: 7 + 35 + 49 = 91
Example 4:
Input: nums = [63, 10, 21]
Return: 84
Explanation: 63 + 21 = 84