Jan-05-2020, 04:08 PM
Hi all!
I'm new to Python and played around a bit with the random module a little as a part of my learning process.
I wanted to do i lottery game that randomly spits out 7 numbers in the range of 1 to 34 and puts them in a list.
The problem is that the random generator will generate the same number more than once. I was able to solve this by generating a new set of numbers if doubles were found. But what i would prefer to do is preventing the random generator to generate already used numbers, as it would in a real lottery game. The used numbers should be excluded from the random generator so to speak. Is this possible to do?
Thanks a lot for your help!
I'm new to Python and played around a bit with the random module a little as a part of my learning process.
I wanted to do i lottery game that randomly spits out 7 numbers in the range of 1 to 34 and puts them in a list.
The problem is that the random generator will generate the same number more than once. I was able to solve this by generating a new set of numbers if doubles were found. But what i would prefer to do is preventing the random generator to generate already used numbers, as it would in a real lottery game. The used numbers should be excluded from the random generator so to speak. Is this possible to do?
Thanks a lot for your help!
for x in range(0, 7): lottorad[x] = random.randint(1, 34)