
April 4, 2023
12:30 p.m.
Hi Here's a similar example $ python3
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux Type "help", "copyright", "credits" or "license" for more information.
from collections import Counter cnt = Counter # Oops! cnt.update('abcde') cnt <class 'collections.Counter'>
This is what happens without the typo.
cnt = Counter()
cnt.update('abcde') cnt Counter({'a': 1, 'b': 1, 'c': 1, 'd': 1, 'e': 1})
Here's a link to the source for Counter.update: https://github.com/python/cpython/blob/3.11/Lib/collections/__init__.py#L658... -- Jonathan