-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteamlab_ds.py
More file actions
50 lines (38 loc) · 1.2 KB
/
teamlab_ds.py
File metadata and controls
50 lines (38 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from typing import Any
class Node():
"""
A class to represent a Node for an explanation of data structure.
...
Attributes
----------
data : Any
data that user store on Node instance
next : Node
object connected to the next node in a linked list.
"""
def __init__(self, data : Any = None, next : 'Node' = None) -> None:
"""
Args:
data (Any, optional): data that user store on Node instance
next (Node, optional): object connected to the next node in a linked list
"""
self._data = None
self._next = None
@property
def data(self):
""" data that user store on Node instance """
return self._data
@data.setter
def data(self, value : Any) -> None:
self._data = value
@property
def next(self):
""" An object connected to the next node in a linked list"""
return self._next
@next.setter
def next(self, node : 'Node') -> None:
self._next = node
def __str__(self) -> str:
return_str = f"I have data : {self._data}\n"
return_str = return_str + f"I have next node : {self._next}"
return return_str