How would you solve a string manipulation problem that also requires interacting with an API?
Implement resolve_tokens(text, api). The input string contains tokens formatted as {{key}}; for each distinct key, retrieve its value from the supplied API-like mapping using api.get(key). Replace known tokens with their values, preserve unknown tokens unchanged, and return the resulting string.
text is a string and api maps string keys to string values. Return one string. Token keys may contain letters, digits, underscores, and spaces after trimming.
{{ and }} delimitersdef resolve_tokens(text, api):