Sum of Numbers Divisible by Three

  • Share this:

Code introduction


This function takes a list of numbers as input and returns the sum of all numbers in the list that are divisible by 3.


Technology Stack : List comprehension, sum function, modulo operator %

Code Type : Function

Code Difficulty : Intermediate


                
                    
def sum_divisible_by_three(numbers):
    return sum(num for num in numbers if num % 3 == 0)