mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Simplify explanation of multiset operations by removing restrictions on negative inputs.
This commit is contained in:
parent
63b3a97a2a
commit
e0d1b9f11f
3 changed files with 17 additions and 24 deletions
|
@ -314,8 +314,8 @@ class Counter(dict):
|
|||
if not isinstance(other, Counter):
|
||||
return NotImplemented
|
||||
result = Counter()
|
||||
for elem, count in self.items():
|
||||
newcount = count - other[elem]
|
||||
for elem in set(self) | set(other):
|
||||
newcount = self[elem] - other[elem]
|
||||
if newcount > 0:
|
||||
result[elem] = newcount
|
||||
return result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue