Skip to main content

Check Collection Length Is N

Validates that a student’s collection (list, tuple, set, etc.) has exactly N elements, optionally enforcing a specific type.

Device Type
Jupyter

Variables:

Variable NameVariable DescriptionTypeRequired?Default
student_collection_variable_nameThe name of the student’s collection variable.strYes
nThe exact number of elements expected.intYes
collection_typeOptional: A Python type to enforce (e.g. 'list', 'tuple'). If not provided, only the length is checked.strNo

Examples: