소스 검색

Version de pendu.py finale

master
Dimitri Merejkowsky 4 년 전
부모
커밋
660d4e582f
1개의 변경된 파일33개의 추가작업 그리고 2개의 파일을 삭제
  1. +33
    -2
      saison-2/sources/pendu.py

+ 33
- 2
saison-2/sources/pendu.py 파일 보기

@@ -11,10 +11,41 @@ def choisir_mot_au_hasard():
return mots[index]



def main():
mot = choisir_mot_au_hasard()
print(mot)
# pour debuggage
# print(mot)
tentatives = []
while True:
afficher_indice(mot, tentatives)
lettre = demander_lettre()
tentatives += [lettre]
if a_gagné(mot, tentatives):
print("Gagné")
print(mot)
break


def a_gagné(mot, tentatives):
for c in mot:
if c not in tentatives:
return False
return True


def demander_lettre():
print("entrer une lettre")
lettre = input()
return lettre


def afficher_indice(mot, tentatives):
for c in mot:
if c in tentatives:
print(c, end="")
else:
print("_", end="")
print()


main()