Skip to content
Snippets Groups Projects
Commit 95b429a1 authored by nilsl99's avatar nilsl99
Browse files

Fixed Stack.__str__

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