File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ def get_data (self):
16
16
def set_data (self , d ):
17
17
self .data = d
18
18
19
- def to_string (self ):
19
+ def __str__ (self ):
20
20
return "Node value: " + str (self .data )
21
21
22
22
class CircularLinkedList (object ):
@@ -71,10 +71,10 @@ def print_list (self):
71
71
if self .root is None :
72
72
return
73
73
this_node = self .root
74
- print (this_node . to_string () )
74
+ print (this_node )
75
75
while this_node .get_next () != self .root :
76
76
this_node = this_node .get_next ()
77
- print (this_node . to_string () )
77
+ print (this_node )
78
78
79
79
def main ():
80
80
myList = CircularLinkedList ()
@@ -87,10 +87,10 @@ def main():
87
87
print ("Find 12" , myList .find (12 ))
88
88
89
89
cur = myList .root
90
- print (cur . to_string () )
90
+ print (cur )
91
91
for i in range (8 ):
92
92
cur = cur .get_next ();
93
- print (cur . to_string () )
93
+ print (cur )
94
94
95
95
print ("size=" + str (myList .get_size ()))
96
96
myList .print_list ()
You can’t perform that action at this time.
0 commit comments