Write a function that takes in a binary string and returns the equivalent decoded text (the text is ASCII encoded).

Each 8 bits on the binary string represent 1 character on the ASCII table.

The input string will always be a valid binary string.

Characters can be in the range from "00000000" to "11111111" (inclusive)

Note: In the case of an empty binary string your function should return an empty string.

Difficulty: introductory

Starter code:

def binary_to_string(binary):
	

Solutions:
def binary_to_string(binary):
    return "".join( [ chr( int(binary[i: i+8], 2) ) for i in range(0, len(binary), 8) ] )

def binary_to_string(binary):
    return "".join(chr(int(binary[i:i+8],2)) for i in range(0,len(binary),8))


def binary_to_string(binary):
    result = ""
    
    while binary:
        result += chr(int(binary[:8], 2))
        binary = binary[8:]
    
    return result

binary_to_string=lambda b:''.join(__import__('binascii').unhexlify('%x' % int('0b'+b[i:i+8],base=2)).decode("utf-8") for i in range(0,len(b),8))

import re

def binary_to_string(binary):
    return re.sub(r'[01]{8}', lambda x: chr(int(x.group(), 2)), binary)

binary_to_string = lambda b: "".join([[chr(l) for l in range(0, 127)][m] for m in [int(b[n: n+8],2) for n in range(0, len(b), 8)]])

def binary_to_string(binary):
    return int(binary, 2).to_bytes(len(binary)//8, "big").decode() if binary else binary

import re

def binary_to_string(bits):
    return ''.join(chr(int(byte, 2)) for byte in re.findall(r'\d{8}', bits))

import re

def binary_to_string(binary):
    return re.sub(r'.'*8, lambda e: chr(int(e.group(), 2)), binary)

import re
def binary_to_string(binary):
    return ''.join(chr(int(e,2))for e in re.findall('.'*8, binary))