in the following script, I'm trying to count each match, for example, I want to count all 3 matches (how many threes in the output) if you run this script it will give you 100 matches.
import random
from collections import Counter
mycoupon = [1, 2, 5, 4, 8, 7]
for _ in range(100):
r = random.sample(range(1, 10), 6)
draws = set(r)
cc = Counter(mycoupon)
dc = Counter(r)
common = cc.keys() & dc.keys()
counts = 0
for cel in common:
counts += min(cc[cel], dc[cel])
#print("My coupon: ", mycoupon)
#print("Draw: ", draws)
print("Matches: ", counts)
I'm trying to count the "counts" output here
counts += min(cc[cel], dc[cel])
How is it possible?
Aucun commentaire:
Enregistrer un commentaire