def replace_char(str1, ch, newch):
    """
    Replaces all occurrences of a character in a string with a new character.
    """
    return str1.replace(ch, newch)