def peek_stack(stack): if stack: return stack[-1] # this will get the last element of stack else: return None