1

As the title says, I'm getting

>> Counter({'red': 2, 'blue': 1}).total()
AttributeError: 'Counter' object has no attribute 'total'

even though it definitely does? Really at a loss here, thanks in advance!

I tried running it in another compiler, and that worked.

Max
  • 99
  • 6

1 Answers1

2

As Terry Spotts pointed out, this method is only available in Python version >=3.10.

Easy workaround:

sum(Counter_object.values())

as mentioned here.

Max
  • 99
  • 6