Feb-21-2021, 06:24 PM
In addition to snippsat excellent answer - as always in programming Counter can be applied differently as well. It can be used in combination with with randint or choices for example:
+>>> import random +>>> from collections import Counter +>>> random.seed(42) # for reproducibility +>>> Counter(random.randint(1, 10) for i in range(1000)) Counter({4: 116, 5: 113, 2: 108, 8: 105, 9: 103, 7: 102, 10: 95, 1: 91, 3: 85, 6: 82}) +>>> Counter(random.choices(range(1, 11), k=1000)) Counter({6: 112, 8: 105, 10: 104, 1: 103, 5: 103, 4: 102, 2: 99, 3: 92, 7: 91, 9: 89})
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.