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
| Name | Type | Description |
|---|---|---|
| iterable | iterable or mapping or None | Iterable of elements or mapping of elements to counts; omitted or None means no positional input. |
| kwargs | object | Additional 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))