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
   | from random import randrange
print("Ce jeu ne se joue qu'à 1 joueur ! L'ordinateur tient le rôle du cacheur et vous du trouveur!")
 
i=0
N=int(input("Saisir le nombre d'essais "))
tentative=['1','2','3','4']
code=[randrange(1,10),randrange(1,10),randrange(1,10),randrange(1,10),]
l=list(set(tentative).intersection(code))
while i<N:
      report=[]
      N -= 1
      if tentative[0] == code[0]:
                report.append("X")
      if tentative[1] == code[1]:
                report.append("X")
      if tentative[2] == code[2]:
                report.append("X")
      if tentative[3] == code[3]:
                report.append("X")
 
      tempCode=sorted(code)
      tempTentative=sorted(tentative)
 
      if tempCode[0]==tempTentative[0]:
                report.append("O")
      if tempCode[1]==tempTentative[1]:
                report.append("O")
      if tempCode[2]==tempTentative[2]:
                report.append("O")
      if tempCode[3]==tempTentative[3]:
                report.append("O")
      i=i+1 | 
Partager