def removedups(word):
if len(word)<=1:
return word
else:
if word[0]==word[1]:
return removedups(word[1:])
else:
return word[0]+removedups(word[1:])
print(removedups('aabbcc'))
I dont get how the recursion works for this case. My knowledge so far is:
1) it skips the base test
2) goes to the recursion call and returns 'abbcc', and then it starts over again:
3) the if statement in recursion call is false so you disregard it
4) The else statement is where i get confused when it says return word[0] +removedups(word[1:]). Does it go the if statement and checks the word('bbcc')

elseclause can be removed, and the secondifcan become oneelif, and moved back an indentation with the lastelse. Proper syntax ;)elsecan be removed. Concise code:p