Repository navigation
Expand file tree
/
Copy pathpendu.py
More file actions
137 lines (106 loc) · 2.81 KB
/
Copy pathpendu.py
File metadata and controls
137 lines (106 loc) · 2.81 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
wordToFind = "test"
fin = False
lettre_chercher = ""
error = 0
max_error = 10
def genere_mot_trouver(mot):
mot_generer = ""
for letter in mot:
mot_generer += "_"
return mot_generer
def dessine_pendu(nb_erreurs):
if nb_erreurs == 0:
("")
elif nb_erreurs == 1:
print("=========")
elif nb_erreurs == 2:
print(" |")
print(" |")
print(" |")
print(" |")
print(" |")
print("=========")
elif nb_erreurs == 3:
print(" +---+")
print(" |")
print(" |")
print(" |")
print(" |")
print(" |")
print("=========")
elif nb_erreurs == 4:
print(" +---+")
print(" | |")
print(" |")
print(" |")
print(" |")
print(" |")
print("=========")
elif nb_erreurs == 5:
print(" +---+")
print(" | |")
print(" O |")
print(" |")
print(" |")
print(" |")
print("=========")
elif nb_erreurs == 6:
print(" +---+")
print(" | |")
print(" O |")
print(" | |")
print(" |")
print(" |")
print("=========")
elif nb_erreurs == 7:
print(" +---+")
print(" | |")
print(" O |")
print(" /| |")
print(" |")
print(" |")
print("=========")
elif nb_erreurs == 8:
print(" +---+")
print(" | |")
print(" O |")
print(" /|\ |")
print(" |")
print(" |")
print("=========")
elif nb_erreurs == 9:
print(" +---+")
print(" | |")
print(" O |")
print(" /|\ |")
print(" / |")
print(" |")
print("=========")
elif nb_erreurs == 10:
print(" +---+")
print(" | |")
print(" O |")
print(" /|\ |")
print(" / \ |")
print(" |")
print("=========")
mot = genere_mot_trouver(wordToFind)
while fin == False:
lettre_chercher = str(input("Proposez une lettre :"))
indice = 0
lettre_trouvee = False
for lettre in wordToFind:
if ((lettre_chercher) == lettre):
mot = mot[:indice] + lettre + mot[indice+1:]
lettre_trouvee = True
indice += 1
if lettre_trouvee == False:
error += 1
if error == max_error:
fin = True
print("Vous avez perdu !")
if "_" not in mot:
print("Félicitations, vous avez trouvé le mot !")
fin = True
print("Mot :" + mot + "\n-----------------------\nEtat du pendu :")
dessine_pendu(error)