I need to make a function that replaces repeated, consecutive characters with a single character, for example:
\'hiiii how are you??\' -> \'hi how are you?\'
from collections import OrderedDict
def removeDupWord(word):
return "".join(OrderedDict.fromkeys(word))
def removeDupSentence(sentence):
words = sentence.split()
result = ''
return ''.join([result + removeDupWord(word) + ' ' for word in words])
sentence = 'hiiii how are you??'
print (removeDupSentence(sentence))
>>> hi how are you?