Collection Methods

collections.Counter.update()

Add counts in place rather than replacing values as dict.update does. Iterable inputs contain elements, not key-value pairs.

Formal Syntax & Structure

python syntaxpython
counter.update(iterable=None, /, **kwargs)

Parameters & Attributes

NameTypeDescription
iterableiterable or mapping or NoneIterable of elements or mapping of elements to counts; omitted or None means no positional input.
kwargsobjectAdditional keyword entries or arguments.

Return Value

None

No return value; the operation changes the receiver in place.

Working Example

Example Snippetpython
import collectionsc=collections.Counter("a")c.update("aab")print(dict(c))
Python Reference