File tree 1 file changed +8
-8
lines changed
1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 15
15
"""
16
16
17
17
18
- def infix_2_postfix (infix : list [ str ] ) -> str :
18
+ def infix_2_postfix (infix : str ) -> str :
19
19
stack = []
20
20
post_fix = []
21
21
priority = {
@@ -130,15 +130,15 @@ def infix_2_prefix(infix: str) -> str:
130
130
...
131
131
ValueError: Invalid bracket position(s)
132
132
"""
133
- infix = list (infix [::- 1 ]) # reverse the infix equation
133
+ new_infix = list (infix [::- 1 ]) # reverse the infix equation
134
134
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 "("
140
140
141
- return (infix_2_postfix ("" .join (infix )))[
141
+ return (infix_2_postfix ("" .join (new_infix )))[
142
142
::- 1
143
143
] # call infix_2_postfix on Infix, return reverse of Postfix
144
144
You can’t perform that action at this time.
0 commit comments