-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmotus2.py
42 lines (32 loc) · 897 Bytes
/
motus2.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
tofind = 'leopard'
print('Number of letters: ' + str(len(tofind)))
display = ' '
for i in range(len(tofind)):
display += '-'
print(display)
print()
found = False
while not found :
guessed = tofind[0] + input(" " + tofind[0])
guessed_list = [guessed[i] for i in range(len(guessed))]
tofind_list = [tofind[i] for i in range(len(tofind))]
result = ['-' for i in range(len(tofind))]
for il, letter in enumerate(tofind):
if guessed_list[il] == tofind[il]:
result[il] = 'o'
guessed_list[il] = '?'
tofind_list[il] = '?'
else:
for il_guessed in range(len(guessed_list)):
if guessed_list[il_guessed] == tofind_list[il]:
result[il_guessed] = 'x'
guessed_list[il_guessed] = '?'
tofind_list[il] = '?'
display = ''
for i in range(len(result)):
display += result[i]
print(display)
print()
if guessed == tofind :
found = True
print (" Bien joué !")