def translate(): with open("proto.out") as f: chars = f.read() string = [] for char in chars.split(' '): c = int(char) if 31 < c < 127: string.append(chr(c)) else: string.append(c) out = munge(string) print out def munge(string_arr): rebuild = [] store = "" for x in string_arr: if type(x) == int: if store: rebuild.append(store) store = "" rebuild.append(x) else: store += x if store: rebuild.append(store) store = "" return rebuild if __name__ == "__main__": translate()