s = "ABCBCA"
t = "BC"
stack = []
len_t = len(t)
for c in s:
stack.append(c)
if len(stack) >= len_t and "".join(stack[-len_t:]) == t:
for i in range(len_t):
stack.pop()
print(stack)
To embed this project on your website, copy the following code and paste it into your website's HTML: