I am trying to make a number generator for a project I am working on, and I need every number to be unique. The range is '0-100000'. I have the following:
for i in range (1,100000):
num = random.randint(0, 100000)
store = num
print (num)
num = random.randint(0, 100000)
if num == store:
num = '-'
print(num)
I can't go through all the outputs in a timely manner, but at a glance, I have seen two issues with them. Firstly, there are repeats, because 'store' gets changed every time, and is only one number. Secondly, one of the outputs, on my current output screen, is '4183053688'. The range doesn't allow for that, so I don't know what happened.
I have only thought of two possible answers. Firstly I have played around with making a list to check whether a number has been used or not, but I haven't found a way to update it as numbers come in, and I will be using so many number in a short time, that manually putting them in is impractical. My second idea is what the code shows. But those problems have already been explained.