Why is empty list not filled again?

Hi all,

When the user presses a specific button, two random items are displayed as text. The first step after pressing the button is to copy a pre-set list (List X) of three items into an empty list (List Y). A random item is then selected from List Y and displayed, after which it is removed to prevent it from being selected again. This process is repeated for the second random item from List Y.

At the start of this function, List X is always copied into List Y.

The issue arises when the button is pressed a third time: List Y is now empty. This is confusing because the first step should always be to refill List Y from List X. It seems that this copying only occurs after the button is pressed the first time. I'm not sure why List Y doesn't refill. Any ideas? I hope my explanation is clear :slight_smile:

Maybe show your relevant blocks...

Did you use the list COPY block to fill list Y?

Or did you just code set Y = X?

The first actually de-links the two lists.

The second points list Y at list X, so that deletion from list Y happens to list X behind the scenes.

AI2 lists are linked lists.

OK. I need to use
image

Thank you

Aha! I guessed right.

1 Like

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