Skip to content

Commit 04174ad

Browse files
authored
Merge pull request joeyajames#60 from Ethan0507/patch-1
Update CircularLinkedList.py
2 parents 92ce92a + 6f4622e commit 04174ad

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

LinkedLists/CircularLinkedList.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def get_data (self):
1616
def set_data (self, d):
1717
self.data = d
1818

19-
def to_string (self):
19+
def __str__(self):
2020
return "Node value: " + str(self.data)
2121

2222
class CircularLinkedList (object):
@@ -71,10 +71,10 @@ def print_list (self):
7171
if self.root is None:
7272
return
7373
this_node = self.root
74-
print (this_node.to_string())
74+
print (this_node)
7575
while this_node.get_next() != self.root:
7676
this_node = this_node.get_next()
77-
print (this_node.to_string())
77+
print (this_node)
7878

7979
def main():
8080
myList = CircularLinkedList()
@@ -87,10 +87,10 @@ def main():
8787
print("Find 12", myList.find(12))
8888

8989
cur = myList.root
90-
print (cur.to_string())
90+
print (cur)
9191
for i in range(8):
9292
cur = cur.get_next();
93-
print (cur.to_string())
93+
print (cur)
9494

9595
print("size="+str(myList.get_size()))
9696
myList.print_list()

0 commit comments

Comments
 (0)