import re


def replace(string, char):
    """
    Function to replace multiple occurrences   
    of a character by a single character 
    """
    pattern = char + '{2,}'
    string = re.sub(pattern, char, string) 
    return string