fix 3.8_08

This commit is contained in:
Dmitry Belyaev 2024-04-16 13:18:11 +03:00
parent 0d65b8a938
commit aa5cfa0124

View File

@ -93,6 +93,22 @@ class Stack:
self.top = obj
else:
self.bottom.next = obj
def pop(self) -> StackObj:
if not self.top:
return None
a, b, c = [self.top] + [None] * 2
while a:
a, b, c = a.next, a, b
if c:
c.next = None
if self.top in [b, c]:
self.top = None
return b
def __len__(self):
count, obj = 0, self.top
@ -128,22 +144,6 @@ class Stack:
else:
self.top = value
def pop(self) -> StackObj:
if not self.top:
return None
a, b, c = [self.top] + [None] * 2
while a:
a, b, c = a.next, a, b
if c:
c.next = None
if self.top in [b, c]:
self.top = None
return b
def get_data(self) -> List[StackObj]:
return [x for x in self]
@ -151,7 +151,7 @@ class Stack:
return f"{self.__class__.__name__}({self.get_data()!r})"
def __str__(self):
return " -> ".join(self.get_data())
return " -> ".join(map(str, self.get_data()))
def tests():