You are viewing a single comment's thread. Return to all comments →
num=13 s=str(bin(num)) print(s) c=0 for i in range(len(s)): if s[i]=='1' and str[i]==str[i+1]: c=c+1
print(c)
it is showing error though the logic is correct. can someone pls explain why
Seems like cookies are disabled on this browser, please enable them to open this website
Consecutive 1's in Binary Numbers
You are viewing a single comment's thread. Return to all comments →
num=13 s=str(bin(num)) print(s) c=0 for i in range(len(s)): if s[i]=='1' and str[i]==str[i+1]: c=c+1
print(c)
it is showing error though the logic is correct. can someone pls explain why