import random
numbers = list(range(1,46))
random.shuffle(numbers)
print( numbers[:6] )
It's a method of randomly picking 6 numbers between 1 and 45. We can do this six times. Find the most extracted number here.
from collections import Counter
Counter([1,2,3,4,5,5,5,5])
I think it'd be good to use that.
I heard that you use repetitive sentences
import random
from collections import Counter
number_list = list(range(1, 46))
count = Counter()
for i in range(6):
lotto = random.sample(number_list, 6) # Extract 6 from list
count.update(lotto)
common = [m[0] for m in count.most_common(6)]
print(common)
© 2024 OneMinuteCode. All rights reserved.