Skip to content

Commit

Permalink
Advanced Task
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronnie5562 committed Jul 24, 2023
1 parent 89956b8 commit ff89bab
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions python-classes/100-singly_linked_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ def __init__(self, data, next_node=None):
"""
self.__data = data
self.__next_node = next_node

@property
"""property(get&set) for the data of the Node."""
def data(self):
"""property(get&set) for the data of the Node."""
return self.__data

@data.setter
def data(self, value):
if (not isinstance(value, int)):
raise TypeError("data must be an integer")
self.__data = value

@property
def next_node(self):
"""property(get&set) for the next_node."""
return self.__next_node

@next_node.setter
def next_node(self, value):
if (not isinstance(value, Node) and value is not None):
Expand All @@ -43,7 +43,7 @@ class SinglyLinkedList:
def __init__(self):
"""Initialize a new SinglyLinkedList."""
self.__head = None

def sorted_insert(self, value):
"""Insert a new Node to the SinglyLinkedList.
Expand All @@ -66,9 +66,9 @@ def sorted_insert(self, value):
current_node = current_node.next_node
new_node.next_node = current_node.next_node
current_node.next_node = new_node

def __str__(self):
"""Defines the print() representation of a SinglyLinkedList obj"""
"""The print() representation of a SinglyLinkedList obj"""
node_list = []
current_node = self.__head
while (current_node is not None):
Expand Down

0 comments on commit ff89bab

Please sign in to comment.