Skip to main content

padlist

Pad list with default elements.

def padlist(
container: iterable,
size: int,
default: any = None
) - > list

Pad list with default elements.

Parameters

NameTypeDescription
containeriterableThe original collection of elements to be padded or truncated
sizeintThe desired final length of the resulting list
defaultany = NoneThe value used to fill the remaining slots if the container is shorter than the target size

Returns

TypeDescription
listA new list containing the original elements truncated or extended with the default value to reach the specified size