Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Check if multi dimensional list element exists in another list

Consider these two lists:

ListA = ["High", [1,2,3], "Medium"]
ListB = [["Low", [3,2,1], "Low"], ["High", [1,2,3], "Medium"]]

Now I want to check if ListA exists in ListB.
In this example, it should give TRUE since ListA equals ListB[1].

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Normally I would convert the list to a set so all duplicates get removed, however, since this is not a flat list I’m stuck finding a good way to solve this.

>Solution :

if ListA in ListB:
    print('ListA exists in ListB.')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading