from random import sample symbols = bytearray(input("Your sequence: ").replace(" ", ""), "utf_8") print(str(bytearray(sample(symbols, 3)), "utf_8")) #print(f"Your word: {bytearray(sample(symbols, 3)).decode(encoding='utf_8')}.")