B.py - CNTDIV
Your task is to write a function count_divisible_by_7(nums)
that counts how many numbers in a given list nums
are divisible by 7. Return the count of numbers that are divisible by 7.
Input:A list of integers nums
.
Output:Return the count of numbers in the list that are divisible by 7.
Example 1:
Input: nums = [7, 14, 20, 21, 28]
Return: 4
Explanation: 7, 14, 21, and 28 are divisible by 7. So, the count is 4.
Example 2:
Input: nums = [1, 2, 3, 4, 5, 6]
Return: 0
Explanation: None of the numbers in the list are divisible by 7.
Example 3:
Input: nums = [7, 15, 35, 49, 50]
Return: 3
Explanation: 7, 35, 49 are divisible by 7, so the count is 3.
Example 4:
Input: nums = [63, 10, 21]
Return: 2
Explanation: 63 and 21 are divisible by 7, so the count is 2.