Creating a subset list from a larger list, based on a different parallel list

30 views
Skip to first unread message

Dave

unread,
Oct 2, 2019, 9:21:24 AM10/2/19
to MIT App Inventor Forum
Hi everyone,
I'm fairly new to app inventor, and I'm having some trouble wrapping my head around this problem.
I'm making something similar to the blocks below, trying to create a list (HeadsOnly) which only includes the names of people who got Heads in the Coin Result.
I've tried fiddling around with the "for each number" block as well, but I'm still not getting it.
Any help would be fantastic.

Also, if it matters, the way the rest of my program is set up, I can't change the layout of the original lists.

Thanks in advance (hopefully)!

blocks.png

Italo

unread,
Oct 2, 2019, 12:31:18 PM10/2/19
to MIT App Inventor Forum
The "item" you are using to point to the name is not the index, it's the item ("Head" or "Tail").
There's a block in the lists section called INDEX IN LIST (thing, list) but you'll need to use a different way of getting the index number from the CoinResult list because you have repetitive items and it will give the wrong index number.
If I were you I would use a FOR EACH NUMBER block instead the FOR EACH item IN LIST block. That way you can increment the index number and use it in both lists.


Italo

unread,
Oct 2, 2019, 12:37:47 PM10/2/19
to MIT App Inventor Forum
This way:

blocks.png


Dave

unread,
Oct 3, 2019, 4:02:17 AM10/3/19
to MIT App Inventor Forum
Thank you Italo, you're a champion!
Reply all
Reply to author
Forward
0 new messages