How do I find Substring Events in a string in Python. I need to do in the hand is this my difficulty, I have to go through the string and if I find two occurrences of the same substring I have to remove one. In the output is counted the number of occurrences of the substrings and return the correct strings. The string is all lowercase and without an accent.
string= str(input('digite palavra:'))
for i in range(len(string)):
x=string[-3:]
y=string[-2:]
if string.find(x)and string.find(y):
a = string
b = x or y
for i in range(0,len(b)):
a =a.replace(b[i],"",1)
Print( a)
Example:
Aulaula - retira' ula' fica Aula
Indodo - retira 'do' fica indo
aa- retira o 'a' fica a
Estavatava- retira o 'tava' fica Estava
In my code I only get with the palalvra 'indodo already with the others stays (Auula, aa, Esravatava)