mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 09:21:13 +08:00
Enable ruff PLR5501 rule (#11332)
* Enable ruff PLR5501 rule * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -95,13 +95,12 @@ def infix_2_postfix(infix: str) -> str:
|
||||
while stack[-1] != "(":
|
||||
post_fix.append(stack.pop()) # Pop stack & add the content to Postfix
|
||||
stack.pop()
|
||||
else:
|
||||
if len(stack) == 0:
|
||||
stack.append(x) # If stack is empty, push x to stack
|
||||
else: # while priority of x is not > priority of element in the stack
|
||||
while stack and stack[-1] != "(" and priority[x] <= priority[stack[-1]]:
|
||||
post_fix.append(stack.pop()) # pop stack & add to Postfix
|
||||
stack.append(x) # push x to stack
|
||||
elif len(stack) == 0:
|
||||
stack.append(x) # If stack is empty, push x to stack
|
||||
else: # while priority of x is not > priority of element in the stack
|
||||
while stack and stack[-1] != "(" and priority[x] <= priority[stack[-1]]:
|
||||
post_fix.append(stack.pop()) # pop stack & add to Postfix
|
||||
stack.append(x) # push x to stack
|
||||
|
||||
print(
|
||||
x.center(8),
|
||||
|
Reference in New Issue
Block a user