def isValidNumber(self, u, i): #if user input is valid answer = True while True: try: self.userInput = Language.getNumber(self) if self.userInput >= u and self.userInput <= i: return self.userInput else: print( "You put an invalid input! Input should be 1 to 5:\n") answer = True except ValueError: print("You put an invalid number!!\n ") True