I have a string say a = "awxxxyyw".
It should remove all the consecutive elements from the string and return me final string as "a".
ie in 1st iteration xxx seems to be consecutive, so remove xxx, then string becomes awyyw.
2nd iteration removes yy. string becomes aww.
3rd iteration remove ww. returns a
Here is my code.
Where I'm going wrong?
def func(string,pointer):
print pointer
for i in range(pointer,len(string)):
flag=0
temp = i
print temp,pointer
try:
while(string[i-1] == string[i]):
print string
i+= 1
flag = 1
except : break
if flag == 0 :
continue
else:
string = string[0:temp] + string[i+1:len(string)]
func(string, temp)
return string
string = "awxxxyyw"
print func(string,1)
'aaxyyza'?