This is a game in which a sequence of 4 characters is displayed to the player, one at a time with a delay between them. Then the player must input that sequence as it was displayed.
Sequences are displayed until input is incorrect.
The characters composing the sequences are chosen at random and they are all lines.
__all__ = [] import random import time from colorama import deinit, init MSG_ASK = 'What was the sequence? ' MSG_CORRECT = '\033[32mCorrect!\033[0m' MSG_INCORRECT = '\033[31mIncorrect\033[0m' def main(): k = 4 lines = r'|\-/' seconds = 1 init() while True: s = '' sequence = random.choices(lines, k=k) sequence = ''.join(sequence) for i in range(k): if not i: s = '' elif i == 1: s = ' ' else: s = i * ' ' print(s, sequence[i], end='\r') time.sleep(seconds) print(f'{s} ') if input(MSG_ASK) == sequence: print(MSG_CORRECT) else: print(MSG_INCORRECT) break deinit() if __name__ == '__main__': main()