Skip to content

Commit bd57b1e

Browse files
author
IanDoarn
committed
Updates to stack.py -thanks @MrDupin
Signed-off-by: IanDoarn <[email protected]>
1 parent e0e9505 commit bd57b1e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pygorithm/data_structures/stack.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def __is_operand(char):
9595
# OLD VERSION
9696
# return ord(char) >= ord('a') and ord(char) <= ord('z') \
9797
# or ord(char) >= ord('A') and ord(char) <= ord('Z')
98-
return True if ord(char) in [ord(c) for c in list(ascii_letters)] else False
98+
return True if ord(char) in [ord(c) for c in ascii_letters] else False
9999

100100
@staticmethod
101101
def __precedence(char):
@@ -127,7 +127,8 @@ def infix_to_postfix(self):
127127
postfix.append(top_operator)
128128
top_operator = self.my_stack.pop()
129129
else:
130-
while not self.my_stack.is_empty() and self.__precedence(self.expression[i] <= self.__precedence(self.my_stack.peek())):
130+
while not self.my_stack.is_empty() \
131+
and self.__precedence(self.expression[i] <= self.__precedence(self.my_stack.peek())):
131132
postfix.append(self.my_stack.pop())
132133
self.my_stack.push(self.expression[i])
133134

0 commit comments

Comments
 (0)