Runtime Error keeps occuring

I am making an app for class where a random food pops on the screen and if you click a healthy food it will give you a point and if you click a junk food it will subtract a point as well as list the macros on your food. I tried to make it so that every time you log into the app out of the 9 foods I have put in the app 2 random foods are shown and then when you click that food it disappears and another 2 random foods are shown. I have implemented a new method to that every time the screen is initialized it will do this but it is giving me complex errors and I need guidance all help is appreciated.

1 Like

In Screen1.Initialize, you pick a random index in a list, then remove that index repeatedly.

AI2 lists are not arrays. They shrink each time you remove an item, and the index numbers collapse to fill the gaps.

That index number will eventually be past the end of the shrinking list.

1 Like