diff --git a/main.py b/main.py index 7742a21b6142065041516a9a30faae9e8b00ae05..89e039db579f2851bfe823a7aa44fddcedc6482f 100644 --- a/main.py +++ b/main.py @@ -39,12 +39,15 @@ class TabletteChocolat: plt.close() def demander_coup(self): + n = 0 x = input("Couper des lignes (l) ou colonnes (c) ? -> ") if x == "l": - n = input("Combien de lignes à couper ? Choix possibles : " + str(list(range(1, self.m))) + " -> ") - return t.coupe(int(n), 0) + while not self.est_possible(int(n), 0): + n = input("Combien de lignes à couper ? Choix possibles : " + str(list(range(1, self.m))) + " -> ") + return self.coupe(int(n), 0) if x == "c": - n = input("Combien de colonnes à couper ? Choix possibles : " + str(list(range(1, self.n))) + " -> ") + while not self.est_possible(0, int(n)): + n = input("Combien de colonnes à couper ? Choix possibles : " + str(list(range(1, self.n))) + " -> ") return t.coupe(0, int(n)) else: return "Il faut répondre l ou c !"