So I have this code:
t=int(input())
while t:
s=int(input())
n=bin(s)
n=n[2:][::-1]
if n.count('1')==1:
pos=n.find('1')+1
print(pos)
else:
print('-1')
t-=1
I would like to know exactly what's going on in this line:
n=n[2:][::-1]
What does [::-1] means?
It takes the reverse of binary value of n excluding "0b" values in the beginning. For example if you enter 6 for value of n. The binary value would be 0b110 and reverse value excluding 0b would be 011.