Discuss Scratch

lollypopbomb2
New Scratcher
1 post

How to check if items in list A are present in list B

I have two lists and I want to count how many items in List A are in List B.

At the moment, I have that if List A contains List B, add 1 to variable C. But this doesn't work because it only adds 1 to variable C if list A and B are exactly identical. But I don't want to see if the lists are identical; I want to know if there are any items in one list that is also in the other list.

Thank you so much for your time! Any help would be greatly appreciated~!
medians
Scratcher
1000+ posts

How to check if items in list A are present in list B

Do you mean like this? (number is the number of common items excluding duplicates) (haven't tested yet)

Index is needed to scan through the list.

Last edited by medians (Jan. 16, 2023 16:35:40)

Powered by DjangoBB