-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.py
78 lines (70 loc) · 2.61 KB
/
index.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import random
in_game = True
while in_game:
words = "aversion col croute lumineux joypop haine elimination invention fleur minimal"
words_list = words.split()
secret = random.randint(0, len(words_list) - 1)
secret_word = words_list[secret]
game = {
"secret_word": secret_word,
"guess_words": "_" * len(secret_word),
"life": 9,
"guess_letters": set()
}
def __game__():
print(f"""
***************************************************************
{game['guess_words']} | vie : {game['life']}
lettres essayé : {game['guess_letters']}
***************************************************************
""")
print(f"""
****************************************
N O U V E L L E P A R T I E P E N D U
{game['guess_words']} | vies : {game['life']}
****************************************
""")
while True:
a = input('Entrez la lettre : ')
if a == '' or a.isnumeric() or len(a) != 1:
print("lettre nom entrez ou valeur numérique")
pass
elif a in secret_word and a not in game["guess_words"]:
game['guess_letters'].add(a)
print(f" Bravo {a} fait parti du mot")
guess_word_list = list(game['guess_words'])
for index, letter in enumerate(game['secret_word']):
if letter == a:
guess_word_list[index] = a
game["guess_words"] = "".join(guess_word_list)
__game__()
elif a not in secret_word:
game['guess_letters'].add(a)
game["life"] -= 1
print(f" {a} ne fait pas parti du mot 💔")
__game__()
if game["guess_words"] == secret_word:
print("You win ! 🏆")
replay = input(f"""
*****************
You want replay ? (y/Y/yes/Yes/O)
*****************
""")
if replay not in ['y', 'Y', "yes", "Yes", "O"]:
in_game = False
break
elif game["life"] < 1:
print(f"You lose ❌ | the word was {secret_word}")
replay = input(f"""
*****************
You want replay ? (y/Y/yes/Yes/O)
*****************
""")
if replay not in ['y', 'Y',"yes","Yes","O"]:
in_game = False
break
match a:
case "y" | "yes" | "oui":
in_game = True
case _:
print("See you soon !")