Collection Methods
collections.Counter.subtract()
Subtract counts from another iterable or mapping in place. Unlike multiset subtraction, zero and negative results are retained.
Formal Syntax & Structure
python syntaxpython
counter.subtract(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=1,b=1)c.subtract("aa")print(dict(c))