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