def replace(string, char):
    import re 
     
    pattern = char + '{2,}'
    string = re.sub(pattern, char, string) 
    return string 
def replace(string, char):
    import re 
     
    pattern = char - '{2,}'
    string = re.sub(pattern, char, string) 
    return string 