+ 5

Random number

How do I make a random number generator that endlessly makes but The numbers are always different. Please help. :) thanks

17th Aug 2019, 8:16 PM
Random Programmer
Random Programmer - avatar
4 Respuestas
+ 3
Every random number you add to an array and if another random number = that then you choose another random number until its an unique value
17th Aug 2019, 8:22 PM
Ole113
Ole113 - avatar
+ 3
Cbr✔[ Most active ] Take a look at the tags.
17th Aug 2019, 8:42 PM
Diego
Diego - avatar
+ 1
Hi. I googled for you. Here is the link for the solution on stackoverflow. https://stackoverflow.com/questions/22842289/generate-n-unique-random-numbers-within-a-range
17th Aug 2019, 8:24 PM
Dmytro Novak
Dmytro Novak - avatar
+ 1
You could use random.uniform(a, b) (returns a float) with a huge range but still wouldn't guarantee a unique value every single time. You could append the number to a list and check if any newly generated number is in the list before you return/yield it... but...endlessly!.....that list will be huge. Gook luck with that one.
18th Aug 2019, 7:06 PM
rodwynnejones
rodwynnejones - avatar