0 out of 464 challenges solved

Count Set Bits

Write a Python function `count_set_bits(n)` that counts the number of set bits (binary digits with value 1) in the binary representation of a given non-negative integer `n`.

#### Example Usage
```python [main.nopy]
count_set_bits(2)  # Output: 1, because binary representation of 2 is '10'
count_set_bits(4)  # Output: 1, because binary representation of 4 is '100'
count_set_bits(6)  # Output: 2, because binary representation of 6 is '110'
```
def count_set_bits(n):
    """
    Count the number of set bits (1s) in the binary representation of a number.

    Args:
        n (int): A non-negative integer.

    Returns:
        int: The count of set bits in the binary representation of n.
    """
    # Initialize the count of set bits
    count = 0
    # Placeholder for the solution
    return count