Generating 9 random numbers with no repeats

Hi,
I’m generating 9 random numbers and I don’t want any repeats.
Each randomly generated number is put on a button later on.
The “ListOfButtons” starts off empty.
Then, as each randomly generated number is generated, it is added to the “ListOfButtons” if it is not in the list.
But for some reason I do get repeats sometimes.
Is there a problem with the “if” statement here,
Thanks,

I would think that would work.

Here’s another way to do this which should be a little faster as there is no condition to check:

You can try it on the first screen here: Thunkable

1 Like

Hi Tatiang,
Thanks for the response.
The problem was I have a list, and didn’t realise that the first counter in the list is at position ‘1’
I took a short cut and used the positions of the numbers as the actual numbers, so everything was out by one.
So I got it to work upon realizing this.
But your code looks a lot cleaner than mine, and I don’t like the ‘=false’ in mine, so I’ll try and plug your code into mine.

Thanks as always.

1 Like

Just one question, does the “get and remove” guarantee that no duplicate will be inserted into the list?

It should.

1 Like