Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-243

Average Chunk Length

Problem

Return the mean length of the chunks described by lengths, or 0.0 when lengths is empty.

Hint

Mean is the sum of lengths divided by the chunk count.

Test cases

case 1
in: [[4,4,2]]
expected: 3.3333333333333335
case 2
in: [[]]
expected: 0
case 3
in: [[5]]
expected: 5
case 4
in: [[1,2,3,4]]
expected: 2.5
Starter codePython
def average_chunk_length(lengths):
    # Your code here
    pass

4 test cases · run your code against them in the editor