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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
| import os
import time
dictionnaire = {}
#mots7lettres.py
#24/02/2018
fic = open("H:\CLE USB\ESTP\INFO ESTP\mots7lettres.txt", "r")
texte = fic.read()
fic.close
import random
random.choice(texte)
liste_mots = texte.split(",")
def mot_à_trouver():
echantillon = random.sample(liste_mots,1)
for i in range(len(echantillon)-1,-1,-1) :
ligne = echantillon[i].strip()
if (' ' in ligne) :
print(i)
liste_mots.pop(i)
A=list(echantillon[0])
A=correction_du_mot_minuscule(A)
return A
def correction_minuscule(lettre):
L1=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','a','a','a','a','c','e','e','e','e','i','i','o','o','o','u','u','u']
L2=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','à','â','ä','ã','ç','é','è','ê','ë','î','ï','ö','ô','õ','ù','û','ü']
for k in range (len(L1)):
if L2[k]==lettre:
return(L1[k])
def correction_majuscule(lettre):
L1=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','A','A','A','C','E','E','E','E','I','I','O','O','O','U','U','U']
L2=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','à','â','ä','ã','ç','é','è','ê','ë','î','ï','ö','ô','õ','ù','û','ü']
for k in range (len(L1)):
if L2[k]==lettre:
return(L1[k])
def correction_du_mot_minuscule(list_mot):
mot=[]
for k in list_mot :
k=correction_minuscule(k)
mot.append(k)
return mot
def correction_du_mot_majuscule(list_mot):
mot=[]
for k in list_mot :
k=correction_majuscule(k)
mot.append(k)
return mot
import sys
def comparaison_de_mot(mot_1,mot_2):
R=list(mot_1)
R==correction_du_mot_minuscule(R)
A=mot_2
L=[]
if R == ['Q'] :
print("Merci d'avoir joué! A bientôt!")
sys.exit(0)
if len(R) > 7 or len(R) < 7 :
print("Vous n'avez pas rentré un mot à 7 lettres. Réessayez")
nouveau_mot = input("Essayez un mot à 7 lettres:")
R=list(nouveau_mot)
for i in range(0, len(R)):
if R[i]==A[i]:
L.append(correction_majuscule(A[i]))
Liste_avancé[i]=L[i]
elif R[i] in A[:i]+A[i+1:]:
L.append(R[i])
elif R[i] not in A[i] :
L.append('-')
return (L,Liste_avancé)
def probleme(L_comparee) :
compteur = 0
for i in range(len(L_comparee)) :
if L_comparee[i] = correction_du_mot_majuscule(L_comparee(i)) :
print ("Bienvenue dans motus veuillez taper votre première proposition !")
print("Rentrer Q pour quitter le jeu à tout moment")
A="salazar"
Liste_avancé=[correction_majuscule(A[0]),'-','-','-','-','-','-']
print ("mot à trouver:", "".join(Liste_avancé))
nombre_essai=0
lettre_bien_placée = 0
while nombre_essai<=4 and '-' in Liste_avancé:
time.sleep(2.0)
nombre_essai+=1
L_comparée,Liste_avancé=comparaison_de_mot(input("entrer proposition:"),A)
time.sleep(2.0)
print('Mot retourné :',"".join(L_comparée))
time.sleep(2.0)
print("Mot en cours:","".join(Liste_avancé))
if nombre_essai<=4 and '-' in Liste_avancé :
print("il vous reste", 5-nombre_essai,"essai(s)")
if nombre_essai==5 and '-' in Liste_avancé :
print('PERDU')
print("Le mot caché était:",A)
if '-' not in Liste_avancé:
print('GAGNE') |
Partager