F5 BIG-IP diagnostics can contain compact log messages that need lightweight character analysis. Given a message and a target character, count every character in the message and return the target's first occurrence.
Implement a function that treats uppercase and lowercase characters as different characters and preserves every character, including spaces and punctuation.
The input consists of:
s, a string containing zero or more characters.target, a string containing exactly one character.Return a dictionary with:
counts: a dictionary mapping each character in s to its number of occurrences.first_index: the zero-based index of the first occurrence of target, or -1 if target does not appear.def analyze_string(s, target):