def bf_compiler(code): mem = [0] * 30000 ptr = head = 0 output = "" while head < len(code): c = code[head] if c == '+': mem[ptr] += 1 elif c == '-': mem[ptr] -= 1 elif c == '>': ptr += 1 elif c == '<': ptr -= 1 elif c == '.': output += chr(mem[ptr]) # ',' has been disabled elif c == '[' and mem[ptr] == 0: count = 1 while count: head += 1 if code[head] == '[': count += 1 elif code[head] == ']': count -= 1 elif c == ']' and mem[ptr] != 0: count = 1 while count: head -= 1 if code[head] == ']': count += 1 elif code[head] == '[': count -= 1 head += 1 return output hw = "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++." print(bf_compiler(hw))