Collection Methods

collections.Counter.elements()

Yield each element repeated according to its positive integer count, in encounter order. Zero and negative counts are ignored.

Formal Syntax & Structure

python syntaxpython
counter.elements()

Return Value

iterator

The iterator result described above.

Working Example

Example Snippetpython
import collectionsc=collections.Counter(a=2,b=-1,c=1)print(list(c.elements()))
Python Reference