Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
Dieses Repo ist archiviert. Du kannst Dateien sehen und es klonen, kannst aber nicht pushen oder Issues/Pull-Requests öffnen.
 
 
 
 
 
 

51 Zeilen
1005 B

  1. import random
  2. def lire_mots():
  3. fichier = open("mots.txt")
  4. contenu = fichier.read()
  5. fichier.close()
  6. mots = contenu.splitlines()
  7. return mots
  8. def choisir_mot_au_hasard(mots):
  9. taille = len(mots)
  10. index = random.randint(0, taille)
  11. return mots[0]
  12. def jouer():
  13. mots = lire_mots()
  14. mot = choisir_mot_au_hasard(mots)
  15. # pour débugger, il faudra enlever cet
  16. # appel à print une fois le code terminé
  17. print("Le mot à deviner est", mot)
  18. tentatives = []
  19. while True:
  20. afficher_indice(mot, tentatives)
  21. lettre = demander_lettre()
  22. if lettre not in tentatives:
  23. tentatives += [lettre]
  24. if a_gagné(mot, tentatives):
  25. print(mot)
  26. print("Gagné")
  27. break
  28. def a_gagné(mot, tentatives):
  29. return False
  30. def demander_lettre():
  31. print("entrer une lettre")
  32. lettre = input()
  33. return lettre
  34. def afficher_indice(mot, tentatives):
  35. print("tentatives", tentatives)
  36. jouer()