Add bits



Problem to sum the length of binary value in each and every list element.



if n = [ 1, 2, 3]

list element    binary value    length
     1                1           1
     2                10          2
     3                11          2

sum of the length => 1+2+2=5



Example-1:


Input    : n = [ 1, 2, 3]
Output   : 5 


Example-2:


Input    : n = [ 2, 5, 6]
Output   : 8 







Solution




n = [ 1, 2, 3]

k = 0

for i in range(len(n)):

    a = n[i]

    b = bin(a)

    k += len(b[2:])

print(k)



Output



5