def buy(self, ag: Agency): try: seatSearch = ag.getList() choice = seatSearch[seatSearch.index( min(seatSearch, key=lambda t: t[2]))] #print(choice, ' ', choice[0], ' ', choice[1], ' ', choice[2]) if (ag.sellToCLient(choice[0], choice[1])): # Travel sleep(10) return choice else: sleep(0.01) self.buy(ag) except: sleep(0.1) print('\n\nThe Client ' + str(currentThread) + ' Could not Find any flights' ) # in case there are more clients than seats