Skip to content
Snippets Groups Projects
Commit 786815ee authored by nilsl99's avatar nilsl99
Browse files

Changed __str__

parent b9ad24c3
Branches
No related tags found
No related merge requests found
...@@ -3,7 +3,12 @@ class Stack(list): ...@@ -3,7 +3,12 @@ class Stack(list):
self.stack = l self.stack = l
def __str__(self): def __str__(self):
return str(self.stack) max_length = len(str(max(self.stack, key=lambda x: len(str(x)))))
result = ""
vert = "\u2502"
for ele in self.stack:
result += vert + str(ele).rjust(max_length) + vert + "\n"
return result + "\u2514" + "\u2500"*max_length + "\u2518"
def push(self, element): def push(self, element):
self.stack.append(element) self.stack.append(element)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment