repl.it
@MATHyou/

Left or Right? - A Memorization Game

Python

Note: Does change!

fork
loading
Files
  • main.py
  • Packager files
  • poetry.lock
  • pyproject.toml
  • requirements.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import random
import replit
from termcolor import colored
from time import sleep
score = 0
rightleft = []
i = 0
def Incorrect(score):
    replit.clear()
    print(colored("Incorrect!", "red"))
    print(colored("Your score: " + str(score), "green"))
    print(colored("Remember: The 'maze' will not change if you restart.\nIt will change only if you restart this game.", "cyan"))
    while True:
        cont = input(colored("Try again? [y/n] ", "cyan"))
        if cont == "y" or cont == "n":
            return cont
        else:
            print(colored("Type 'y' for yes and 'n' for no.", "red"))
while i <= 50:
    rightleft.append(random.randint(0,1)) 
    i += 1
MainLoop = True
while MainLoop:
    print(colored("Score: " + str(score), "cyan"))
    while True:
        choice = input(colored("[L]eft or [R]ight? ", "cyan"))
        if choice == "l":
            num = 0
            break
        elif choice == "r":
            num = 1
            break
        else:
            print(colored("Type 'r' for right and 'l' for left.", "red"))
    if rightleft[score] == num:
        score += 1
        replit.clear()
        print(colored("Correct!", "green"))
        sleep(1)
        replit.clear()
    else:
        if Incorrect(score) == "y":
            replit.clear()
            score = 0
        else:
            replit.clear()
            print(colored("Bye!", "blue"))
            MainLoop = False