Advertisement
here2share

# idx_binary.py

Dec 27th, 2024
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. # idx_binary.py
  2.  
  3. def idx_binary(binary_string):
  4.     indices = []
  5.     idx = 0
  6.     while 1:
  7.         idx = binary_string.find('1', idx)
  8.         if idx == -1:
  9.             break
  10.         indices.append(idx)
  11.         idx = idx + 1
  12.     return indices
  13.  
  14. binary_string = '00110100'
  15. indices = idx_binary(binary_string)
  16. print(indices)
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement