Skip to content

Commit 75865f6

Browse files
committed
refactor: add black formatter python default fmt
1 parent 19a147f commit 75865f6

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/python/dynamic_stack.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Stack: Last In - First Out (LIFO)
22

3+
34
# Define node format: value and a pointier to next
45
class Node:
56
def __init__(self, value: int) -> None:
@@ -10,48 +11,49 @@ def __init__(self, value: int) -> None:
1011
class DynamicStack:
1112
def __init__(self) -> None:
1213
self.__first = None
13-
14+
1415
def isEmpty(self) -> bool:
1516
if not self.__first:
1617
return True
1718
return False
18-
19-
def push(self,value: int):
19+
20+
def push(self, value: int):
2021
node = Node(value)
2122
node.next = self.__first
2223
self.__first = node
2324

2425
def pop(self) -> int:
2526
if self.isEmpty():
26-
raise Exception('Stack is empty!')
27+
raise Exception("Stack is empty!")
2728
removedElement = self.__first.value
2829
self.__first = self.__first.next
2930
return removedElement
30-
3131

3232
def show(self) -> None:
3333
node = self.__first
34-
print('[', end=' ')
35-
while(node):
36-
print(node.value, end=' ')
34+
print("[", end=" ")
35+
while node:
36+
print(node.value, end=" ")
3737
node = node.next
38-
print(']')
38+
print("]")
39+
3940

4041
def main() -> None:
4142
dynamic_stack = DynamicStack()
4243

43-
print(f'Push(1,2,4):')
44+
print(f"Push(1,2,4):")
4445
dynamic_stack.push(1)
4546
dynamic_stack.push(2)
4647
dynamic_stack.push(4)
47-
48+
4849
dynamic_stack.show()
4950

50-
print(f'Remove last: {dynamic_stack.pop()}')
51-
print(f'Remove last: {dynamic_stack.pop()}')
52-
print(f'Remove last: {dynamic_stack.pop()}')
53-
print('Empty stack!')
51+
print(f"Remove last: {dynamic_stack.pop()}")
52+
print(f"Remove last: {dynamic_stack.pop()}")
53+
print(f"Remove last: {dynamic_stack.pop()}")
54+
print("Empty stack!")
5455
dynamic_stack.show()
5556

57+
5658
if __name__ == "__main__":
57-
main()
59+
main()

0 commit comments

Comments
 (0)