Sep-20-2020, 06:56 PM

Hey, I am creating a "horse race" game for a class project. So I have to simulate 16 random numbers, and the player has to guess the 5 firsts. So he can win the "ordre", when he have guessed the 5, the "desordre" when he've guessed the 5 but not in the correct order, and finally the "Bonus 3" and "Bonus 4" when he've guessed the first 3 or 4. So, I have made a few functions, for the "ordre", for the simulation of the random numbers ( simule_arrivee ) and for the "desordre" and the bonus ( comparaison ), but I have to make a function that I'll have too call to simulate the entire game ( joue_quinte(pari) ) in which the parameter will be replaced by the player when calling it in the shell. So I have created this function, but I have no clue on how to do it... Anyone could help pls ? ( sorry for my english and for the french names in the code btw ^^' )

import random def simule_arrivee(tabjeu): for i in range (1, 6): variable = random.randrange(1, 17) while variable in tabjeu: variable = random.randrange(1, 17) tabjeu.append(variable) return tabjeu def joue_quinte(pari): tableau_pari=[] tableau_jeu=[] for i in pari: tableau_pari.append(i) def ordre(tabjeu, tabpari): compteur = 0 for i in range(0,5): if tabjeu[i] == tabpari[i]: compteur += 1 if compteur == 5: return "Ordre" def comparaison(tabjeu, tabpari) : compteur_bis= 0 for i in range(len(tabjeu)): for j in range(len(tabpari)): if tabpari[j] == tabjeu[i] : compteur_bis +=1 if compteur_bis == 3: return "Bonus 3" elif compteur_bis == 4: return "Bonus 4" elif compteur_bis == 5: return "Désordre"