title: How to convert binary to string python?
body: <p>I have a dilemma where I have a string of binary code that is all one line. Like this <code>0110000101110000011100000110110001100101</code> (or <code>apple</code>), but I need a way to read every 8 characters to form the full code for the letter so I can convert it.</p>
  
  <p>For some background on how I store the binary, I store it in a dict with the keys as the letters and binary as a string: <code>binary = {"a": "01100001"}</code>, later I swap the keys and values. I can't find a way to read the string in 8 characters chunks like so <code>01100001 = a</code> or <code>01100101 = e</code>, but it has to happen all at once in a for a loop.</p>
  
  <pre class="lang-py prettyprint-override"><code>def binary_string(bin):
      res = dict((v, k) for k, v in binary.items())
      data = []
      for bit in bin:
          if bit in res:
              data.append(res[bin])
          else:
              print("Couldn't find " + bit + "'s letter")
      load = str(data).strip("[]")
      return load
  </code></pre>
  
  <p>I am looking for a way to say: for every 8 characters in this string: append the letter equivalent to a list, and from there I have no problem creating the output to my desire.</p>