All problems
Average Characters per Token
Problem
Compute the average number of characters per token across texts. Divide the total number of characters in texts by the total of token_counts.
Return 0.0 when the total token count is zero.
Hint
Sum lengths and token counts separately, then divide once at the end.
Test cases
case 1
in: [["hello","world"],[2,1]]
expected: 3.3333333333333335
case 2
in: [[],[]]
expected: 0
case 3
in: [["a"],[0]]
expected: 0
case 4
in: [["ab","cd"],[1,1]]
expected: 2
Starter codePython
def average_chars_per_token(texts, token_counts):
# Your code here
pass4 test cases · run your code against them in the editor