Skip to content

Commit 138449c

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent b226362 commit 138449c

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Diff for: data_structures/stacks/infix_to_prefix_conversion.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def infix_2_postfix(infix: str) -> str:
3232
print(
3333
"Symbol".center(8),
3434
"Stack".center(print_width),
35-
"Postfix".rjust((print_width-7) // 2 + 7),
35+
"Postfix".rjust((print_width - 7) // 2 + 7),
3636
sep=" | ",
3737
)
3838
print("-" * (print_width * 3 + 7))
@@ -60,20 +60,20 @@ def infix_2_postfix(infix: str) -> str:
6060
):
6161
post_fix.append(stack.pop()) # pop stack & add to Postfix
6262
stack.append(x) # push x to stack
63-
63+
6464
if post_fix != []:
6565
print(
6666
x.center(8),
6767
("".join(stack)).ljust(print_width),
6868
"".join(post_fix),
6969
sep=" | ",
70-
) #Output in tabular format
70+
) # Output in tabular format
7171

72-
else: # Post_fix is empty -> remove trailing space in table
72+
else: # Post_fix is empty -> remove trailing space in table
7373
print(
7474
x.center(8) + " | " + ("".join(stack)).ljust(print_width) + " |"
75-
) #Output in tabular format
76-
75+
) # Output in tabular format
76+
7777
while len(stack) > 0: # while stack is not empty
7878
if stack[-1] == "(": # open bracket with no close bracket
7979
raise ValueError("Invalid bracket position(s)")
@@ -85,7 +85,6 @@ def infix_2_postfix(infix: str) -> str:
8585
"".join(post_fix),
8686
sep=" | ",
8787
) # Output in tabular format
88-
8988

9089
return "".join(post_fix) # return Postfix as str
9190

0 commit comments

Comments
 (0)