Advertisement
Shivaram-Agnijan

Untitled

Sep 23rd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. def test(i, y):
  2. if y[i] == "<" and i > 0 and y[i-1] == ">":
  3. return False
  4. if y[i] == ">" and i >= len(y) - 1:
  5. return True
  6. if y[i] == ">" and i < len(y):
  7. i += 1
  8. return test(i, y)
  9. if y[i] == "<" and i == 0:
  10. return True
  11. if y[i] == "<" and i > 0:
  12. i -= 1
  13. return test(i, y)
  14.  
  15. n = int(input())
  16. y = input()
  17. y = list(y)
  18. x = 0
  19. for i in range(0, n):
  20. if test(i, y):
  21. x += 1
  22. print(x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement