Show random item from listview then remove that item from showing again

In a virtual screen I make a list
For example:

  1. Alpha
  2. Beta
  3. Charlie
  4. Delta

And in another virtual screen I press a button named change to show a random item from that list, but when I press it again I want the previous displayed item from being a possibility in the new random selection from being shown.
Example 2:

  1. Alpha
  2. Beta
  3. Delta

And when all options are gone, for the the cycle to start again from the beginning. And this while using tinyDB.

I tried making 2 lists:

  1. listOfHobbies is the list I use to save all the items I made to be saved and reused.
  2. randomList is the list I use to show the random item.

What I tried to do (and failed) is when displaying an item I copy a new list which list no.2 and then delete that item from list no.2, so when I press the change button the previous item isn't there to selected again.

Any ideas?

Don't use the pick a random item block when you need to remember the index you chose.

Instead, use the pick a random integer from 1 to length of list (list that you want to deplete).

That way, you have a number you can feed to the block that removes an item.

1 Like

Thanks for the help, your hint actually helped me solve it.

In your opinion is the idea of depleting another list efficient or is there a better way of doing things?


For small data like this, concentrate on getting it right over efficiency, which is imperceptible.

For example, did you want to update the ListView after removing an item?

1 Like

I see, so basically if it works it works.

I needed the invisible listview to be updated not the main one. But thanks for the help.

But considering my project I might need to use clock to make the list time based so that it also changes after on a new day after determined amount of time. I need to learn how to use it 1st and might need to make another post on that

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.