Sum of integers divisible by 3 in a list

The function should take a list of integers as input and return the sum of the integers in the list that are divisible by 3.

Problem

Given a list of integers, write a function that returns the sum of the integers in the list that are divisible by 3.
Example input: [1, 2, 3, 4, 5, 6, 7, 8, 9]
Example output: 18

Solution

This solution is in Python. Our A.I. can create solutions in multiple languages.
by kayakane
def sum_divisible_by_3(list):
    sum = 0
    for i in list:
        if i % 3 == 0:
            sum += i
    return sum

print(sum_divisible_by_3([1, 2, 3, 4, 5, 6, 7, 8, 9]))

A.I. Evaluation of the Solution

The candidate's solution correctly returns the sum of the integers in the list that are divisible by 3. The candidate has used a for loop to iterate through the list and check if each integer is divisible by 3. If it is, the integer is added to the sum. This is a valid approach to solving the problem.

Evaluated at: 2022-11-25 12:16:09