-
Notifications
You must be signed in to change notification settings - Fork 0
/
MemoryGame.py
38 lines (30 loc) · 857 Bytes
/
MemoryGame.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
from random import sample
from time import sleep
def generate_sequence(diff):
seq = sample(range(0, 102), diff)
return seq
def get_list_from_user():
usr_list = [int(x) for x in input("What was the sequence?\n"
"If you remember, enter the numbers separated by a comma.\n").split(', ')]
return usr_list
def is_list_equal(a, b):
if a == b:
return True
else:
return False
def play(diff):
print("Get Ready!\nThe game will start in 3 seconds.")
sleep(3)
seq = generate_sequence(diff)
print(seq)
sleep(1)
print("\n" * 100)
try:
win = is_list_equal(get_list_from_user(), seq)
except ValueError:
win = False
if win is True:
print("You Win!")
else:
print(f"You Lose!\nThe sequence was {seq}.")
return win