Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import sys
- def correct_paren(expr: str) -> bool:
- stack = []
- for char in expr:
- if char in '([{':
- stack.append(char)
- elif char == ')':
- if len(stack) == 0 or stack.pop() != '(':
- return False
- elif char == ']':
- if len(stack) == 0 or stack.pop() != '[':
- return False
- elif char == '}':
- if len(stack) == 0 or stack.pop() != '{':
- return False
- return len(stack) == 0
- def main() -> int:
- if correct_paren(input()):
- print("ano")
- return 0
- else:
- print("nie")
- return 0
- if __name__ == '__main__':
- sys.exit(main())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement