Python Forum
Python - List - Int List
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python - List - Int List
#5
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
Reply


Messages In This Thread
Python - List - Int List - by sophi - Apr-20-2022, 11:24 AM
RE: Python - List - Int List - by Larz60+ - Apr-20-2022, 01:11 PM
RE: Python - List - Int List - by sophi - Apr-20-2022, 01:16 PM
RE: Python - List - Int List - by deanhystad - Apr-20-2022, 05:03 PM
RE: Python - List - Int List - by sophi - Apr-20-2022, 06:59 PM
RE: Python - List - Int List - by deanhystad - Apr-20-2022, 10:02 PM
RE: Python - List - Int List - by sophi - Apr-21-2022, 07:35 PM
RE: Python - List - Int List - by deanhystad - Apr-21-2022, 07:52 PM
RE: Python - List - Int List - by sophi - Apr-21-2022, 07:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to reverse a list and store in another list in python SuperNinja3I3 6 3,403 Aug-14-2022, 06:36 PM
Last Post: DeaD_EyE
  question on list in Python spalisetty06 1 2,082 Jun-30-2020, 09:03 AM
Last Post: pyzyx3qwerty
  Python list exercize ESTOUR 3 1,983 May-23-2020, 11:10 PM
Last Post: ESTOUR
  Python Adding +1 to a list item cointained in a dict ElReyZero 1 2,109 Apr-30-2020, 05:12 AM
Last Post: deanhystad
  Check if a list exists in given list of lists Daniel94 2 2,295 Apr-07-2020, 04:54 PM
Last Post: deanhystad
  list of strings to list of float undoredo 3 2,744 Feb-19-2020, 08:51 AM
Last Post: undoredo
  arrays sum list unsupported operand type(s) for +=: 'int' and 'list' DariusCG 7 4,307 Oct-20-2019, 06:24 PM
Last Post: Larz60+
  have homework to add a list to a list using append. celtickodiak 2 2,073 Oct-11-2019, 12:35 PM
Last Post: ibreeden
  Search character from 2d list to 2d list AHK2019 3 2,547 Sep-25-2019, 08:14 PM
Last Post: ichabod801
  I donr know how to search from 2d list to 2d list AHK2019 1 1,792 Sep-25-2019, 01:59 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020