Advertisement
coockie27

Untitled

Oct 22nd, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. list_index_deg = []
  2. for i in range(len(str)):
  3. if str[i] == '^':
  4. list_index_deg.append(i)
  5.  
  6. for index in list_index_deg:
  7. if str[index - 1].islower():
  8. expression = str[index - 1]
  9. if str[index - 1] == ')':
  10. count = 1
  11. expression = ''
  12. copy_index = index-1
  13. while count > 0 and copy_index >= 0:
  14. if str[copy_index] == ')':
  15. count += 1
  16. if str[copy_index] == '(':
  17. count -= 1
  18. expression = str[copy_index] + expression
  19. copy_index -= 1
  20.  
  21. print(expression)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement