import sys import random import time if sys.stdin.isatty(): word = list(input("Gib das zu erratende Wort ein:\n>")) else: word = list(sys.stdin.read().strip()) printable_ascii = [ ' ', '!', '"', '#', '$', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~' ] guess = [] for i in word: guess.append(random.choice(printable_ascii)) print("".join(guess), end="") while True: if guess != word: for l in range(len(guess)): if guess[l]!=word[l]: guess[l]=random.choice(printable_ascii) print("\r"+"".join(guess), end="", flush=True ) time.sleep(0.05) else: break