Skip to content
a
p = 'ababcabccabc'
ABC='ABC'
def fix_string(s):
s=s.upper()
sequence_length=len(s)
while True:
found = False
for i in range(len(s) - sequence_length + 1):
if ABC in s:
s=s.replace("ABC", "")
found= True
break
if not found:
if len(s) == 0:
return '-1'
else:
break
return s
print(fix_string(p))
# def remove_sequence_from_string(input_string, sequence):
# sequence_length = len(sequence)
# while True:
# found = False
# for i in range(len(input_string) - sequence_length + 1):
# if input_string[i:i + sequence_length] == sequence:
# input_string = input_string[:i] + input_string[i + sequence_length:]
# found = True
# break
# if not found:
# if len(input_string) == 0:
# return-1
# else:
# break
# return input_string
# # Example usage:
# input_str = 'ababcabccabc'
# sequence_to_remove = "abc"
# result = remove_sequence_from_string(input_str, sequence_to_remove)
# print(result)