It has [difficulty:: medium]

def count_set_bits(n):
    """
    Counts the total number of set bits in the binary representation of n.
    """
    # convert n to binary string
    binary_str = bin(n)[2:]
    
    # count number of set bits
    set_bits = 0
    for bit in binary_str:
        if bit == '1':
            set_bits += 1
    
    return set_bits
 
# example usage
num = 100
set_bits = count_set_bits(num)
print(f"The number of set bits in the binary representation of {num} is {set_bits}")