Your question is String Manipulation or Data Parsing. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
IBM Instana alert events may include compact label strings such as service=checkout;severity=critical;region=us-east. Implement a function that parses this string into a dictionary of label names and values.
Each pair is separated by a semicolon, and the key and value are separated by the first equals sign. Remove leading and trailing whitespace from each pair, key, and value. Values may contain additional equals signs, which must remain part of the value.
Given a non-empty string labels, return a dictionary mapping each label key to its string value. Every input pair contains exactly one non-empty key. Keys are unique, and the input does not contain empty pairs.
def parse_instana_labels(labels):