Guest User

Untitled

a guest
Dec 9th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. def fn(thing):
  2.  
  3. #thing = thing[1:]
  4. #print(thing)
  5. final_stack = ["this is final stack"]
  6. index = 0
  7. strlen = len(thing)
  8. shape_stack = []
  9.  
  10. #while index < strlen:
  11. for x in thing:
  12.  
  13. count = 0
  14.  
  15. if thing[index] == "(":
  16.  
  17. count = count + 1
  18. shape_stack.append(thing[index])
  19. index = index + 1
  20. #return count
  21.  
  22. elif thing[index] == ")":
  23.  
  24.  
  25. count = count - 1
  26. print(count)
  27. shape_stack.append(thing[index])
  28. index = index + 1
  29.  
  30.  
  31. if count == 0:
  32.  
  33. print ("this is the break between shapes", shape_stack)
  34. final_stack.append(shape_stack)
  35.  
  36. break
  37. else:
  38.  
  39. pass
  40. else:
  41.  
  42. shape_stack.append(thing[index])
  43. print(shape_stack)
  44. index = index + 1
  45.  
  46. #this is where break goes
  47.  
  48. return final_stack
  49.  
  50.  
  51. #open_bracket = ["("]
  52.  
  53. #shape_stack = open_bracket + shape_stack
  54.  
  55.  
  56. hi = fn(inputparsed)
  57. print (hi)
Add Comment
Please, Sign In to add comment