forked from xavier/KidsCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpendu.py
More file actions
36 lines (29 loc) · 660 Bytes
/
pendu.py
File metadata and controls
36 lines (29 loc) · 660 Bytes
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
# -*- coding: UTF-8 -*-
from kidscode import ask
from random import randint
mot_a_trouver = "PENDU"
lettres = []
trouve = False
essais = 5
while (not trouve) and essais > 0:
mot_cache = ""
for lettre in mot_a_trouver:
if lettre in lettres:
mot_cache += lettre
else:
mot_cache += "-"
print mot_cache
if mot_cache == mot_a_trouver:
trouve = True
else:
print "Lettres:", lettres
print "Essais: ", essais
lettre = ask("Lettre? ").upper();
lettres.append(lettre)
if not lettre in mot_a_trouver:
essais = essais - 1
print "-" * 20
if trouve:
print "C'est gagné! :)"
else:
print "Pendu... :("