Guest User

Untitled

a guest
May 25th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. n = raw_input()
  4.  
  5. alpha = "qwertyuiopasdfghjklzxcvbnm"
  6. signs = "+-*/^"
  7.  
  8. for line in range(int(n)):
  9. expression = raw_input()
  10. sign_stack = []
  11. output = ""
  12.  
  13. for char in expression:
  14. if char in alpha:
  15. output += char
  16. elif char in signs:
  17. sign_stack.append(char)
  18. elif char == ")":
  19. output += sign_stack.pop()
  20.  
  21. print output
Add Comment
Please, Sign In to add comment