I'm trying to solve this exercise using enumerate, but I don't have any idea how to implement the value. In a mathematical way I said if for index and index+1 letter is the same do nothing, if the upcoming letter is different write letter. But I have no idea how to do it in python
Desired result aaabbbaas
=> abas
.
def zad6(string):
b =""
for index,letter in enumerate(string):
if letter[index] == letter[index+1]:
b += None
else:
b += letter
return b
print(zad6("aaabbbaas"))