File: adv_pendu.py

package info (click to toggle)
turing 0.11~beta-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 10,152 kB
  • sloc: python: 103,898; xml: 101; makefile: 50; sh: 29
file content (41 lines) | stat: -rw-r--r-- 642 bytes parent folder | download | duplicates (4)
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
mots = [
    "BONJOUR", 
    "ORDINATEUR", 
    "CLAVIER", 
    "SOURIS", 
    "CHEVAL", 
    "OISEAU", 
    "CHIEN"
]

mot = choix(mots)

saisi = ["_"] * taille(mot)

essais = 10

while True:
    if essais <= 0:
        print("Vous avez perdu !")
        print("Le mot était : " + mot)
        break

    print(" ".join(saisi))

    if saisi == list(mot):
        print("Vous avez gagné !")
        break

    print("%d essais restants" % essais)

    lettre = maju(input("? "))

    for i in range(taille(mot)):
        if mot[i] == lettre:
            saisi[i] = lettre

    if lettre not in mot:
        essais -= 1

    print(" ")