Apr-20-2022, 06:59 PM
class IntList(list): def __init__(self): super().__init__() self.list = [] def __len__(self): return len(self.list) def append(self, elem): if not isinstance(elem, int): raise TypeError('x musí byť typu Integer') self.list[len(self.list):] = [elem] def insert(self, index, value): if not isinstance(value, int): raise TypeError('x musí byť typu Integer') self.list.insert(index, value) def get_list(self): return self.list def __str__(self): return f'{self.list}' def extend(self, listt): if not isinstance(listt, IntList): raise TypeError('Zoznam musí byť typu Integer') z = self.list y = listt.get_list() self.list = z + y print(self.list) return self.list @property def sort(self): x = len(self.list) for i in range(x): for j in range((i + 1), x): if self.list[i] > self.list[j]: l1 = self.list[i] self.list[i] = self.list[j] self.list[j] = l1 return self.list