I am currently working on a flask app for school where I have to generate a random unique set of numbers.
My current code is this:
amount_of_positions = 6
amount_of_numbers = 6
number_set = set()
while len(number_set) < amount_of_positions:
rnd = random.randrange(1, amount_of_numbers + 1)
number_set.add(rnd)
The rnd variable is generating correct random numbers. But when I add that number in the set it gets placed in order instead of at the end of the set.
The result of the above code is: {1, 2, 3, 4, 5, 6}
I can't figure out why it keeps ordering the numbers. Can anyone help me?