Amagi Stream processes caption text and needs to measure how often a selected character appears. Given a string, a single-character target, and a case-sensitivity setting, return the number of matching occurrences.
Implement the function without using built-in substring-counting methods such as str.count().
text: a string containing zero or more printable ASCII characters.target: a string containing exactly one printable ASCII character.case_sensitive: a Boolean. If True, only exact matches count. If False, uppercase and lowercase versions of the target are treated as equal.text.Each character is evaluated independently. For example, if target is "a" and matching is case-insensitive, both "a" and "A" contribute to the result.
def count_character_occurrences(text, target, case_sensitive):