-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.py
41 lines (33 loc) · 890 Bytes
/
node.py
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
## Node Class
## Author: Grant Gasser
## Date: 7/17/2019
# Define a Node
class Node:
"""
Each node has a value and pointer to next node (not doubly for now)
"""
def __init__(self, data):
"""
A class to represent a node in a linked list
Args:
data (int): the data to be stored in node
next (Node): a pointer to the next node in the list
"""
self.data = data
self.next = None
def get_data(self):
"""
Returns data
"""
return self.data
def __str__(self):
"""
Overloading magic method. Turn object into printable string.
"""
return str(self.data)
def __repr__(self):
"""
Overloading magic method. Determine what to print when object typed
into interpreter.
"""
return str(self.data)