Skip to content

Commit 91a6493

Browse files
authored
Fix type hint errors
1 parent 6b78ef5 commit 91a6493

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Diff for: data_structures/stacks/infix_to_prefix_conversion.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"""
1616

1717

18-
def infix_2_postfix(infix: list[str]) -> str:
18+
def infix_2_postfix(infix: str) -> str:
1919
stack = []
2020
post_fix = []
2121
priority = {
@@ -130,15 +130,15 @@ def infix_2_prefix(infix: str) -> str:
130130
...
131131
ValueError: Invalid bracket position(s)
132132
"""
133-
infix = list(infix[::-1]) # reverse the infix equation
133+
new_infix = list(infix[::-1]) # reverse the infix equation
134134

135-
for i in range(len(infix)):
136-
if infix[i] == "(":
137-
infix[i] = ")" # change "(" to ")"
138-
elif infix[i] == ")":
139-
infix[i] = "(" # change ")" to "("
135+
for i in range(len(new_infix)):
136+
if new_infix[i] == "(":
137+
new_infix[i] = ")" # change "(" to ")"
138+
elif new_infix[i] == ")":
139+
new_infix[i] = "(" # change ")" to "("
140140

141-
return (infix_2_postfix("".join(infix)))[
141+
return (infix_2_postfix("".join(new_infix)))[
142142
::-1
143143
] # call infix_2_postfix on Infix, return reverse of Postfix
144144

0 commit comments

Comments
 (0)