Lexicographically Smallest String - Company-specific OAs / Microsoft OA

https://algo.monster/problems/lexicographically_smallest_string

Getting a weird error where the string method replaceAll isn’t being recognized as a function.

Please correct the unit testing.
The code solution is correct, but when I used custom input “abc”, the expected result is “ac”. The code output is “ab”, which is correct.

def smallest_string(s: str) → str:
# WRITE YOUR BRILLIANT CODE HERE
n = len(s)
stack = [s[0]]
flag = True
for i in range(1,n):
if flag and len(stack) > 0 and s[i]< stack[-1]:
flag = False
stack.pop(-1)
stack.append(s[i])
if flag:
stack.pop(-1)
return “”.join(stack)

if name == ‘main’:
s = input()
res = smallest_string(s)
print(res)