diff --git a/examen.py b/examen.py index 3672d32590ce173886522f90cd556a16727b138c..02e9f61e139cc3e0a7f8d1283472695d72aad815 100644 --- a/examen.py +++ b/examen.py @@ -75,11 +75,19 @@ class TabletteChocolat: def demander_coup(self): demande = input('Couper des lignes (l) ou colonnes (c) ?') if demande == 'l': - reponse = int(input("Combien ? En sachant qu'il y a " + str(self.m-1) +" possibilités")) - return (reponse,0) + while(True): + reponse = int(input("Combien ? En sachant qu'il y a " + str(self.m-1) +" possibilités")) + if 1 <= reponse < self.m -1: + return (reponse,0) + else: + print('coup non valide') elif demande == 'c': - reponse = int(input("Combien ? En sachant qu'il y a "+ str(self.n - 1)+ " possibilités")) - return (0, reponse) + while(True): + reponse = int(input("Combien ? En sachant qu'il y a "+ str(self.n - 1)+ " possibilités")) + if 1 <= reponse < self.m -1: + return (0,reponse) + else: + print('coup non valide') #Programme Principal