This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Counter not supported add in Python 3.x
Type: Stage: resolved
Components: Versions: Python 3.10
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: iritkatriel, landpack, rhettinger
Priority: normal Keywords:

Created on 2021-02-08 21:11 by landpack, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg386667 - (view) Author: Frank AK (landpack) Date: 2021-02-08 21:11
In python 3.10, you couldn't plus two Counter instance, you will got the below tip:

```
>>> from collections import Counter
>>> x={1:['a','b','c']}
>>> y={1:['d','e','f'],2:['g']}
>>> Counter(y) + Counter(x)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/frank/github.com/cpython/Lib/collections/__init__.py", line 797, in __add__
    if newcount > 0:
TypeError: '>' not supported between instances of 'list' and 'int'
```

But in Python 2, you got the desire result like :

```
>>> from collections import Counter
>>> x={1:['a','b','c']}
>>> y={1:['d','e','f'],2:['g']}
>>> Counter(x) + Counter(y)
Counter({2: ['g'], 1: ['a', 'b', 'c', 'd', 'e', 'f']})
```
msg386693 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-02-09 05:43
That’s correct. This changed in python 3. See section about ordering comparisons in

https://docs.python.org/3.0/whatsnew/3.0.html
History
Date User Action Args
2022-04-11 14:59:41adminsetgithub: 87337
2021-02-09 05:43:56iritkatrielsetstatus: open -> closed

nosy: + iritkatriel
messages: + msg386693

resolution: not a bug
stage: resolved
2021-02-09 01:58:24xtreaksetnosy: + rhettinger
2021-02-08 21:11:25landpackcreate