-1

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].

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.

Azrion
  • 117
  • 2
  • 14

1 Answers1

1
if ListA in ListB:
    print('ListA exists in ListB.')
  • this doesnt work – Azrion Jan 16 '22 at 13:15
  • @Azrion why it does not work? Can you put an example? – arshovon Jan 16 '22 at 13:17
  • @Azrion, I checked it in the Python interpreter before posting. Why do you say it doesn't work? Can you share your code? –  Jan 16 '22 at 13:22
  • ok i figured it out its my dumb mistake with a bug... i change ListA[0] to some random value and then checked if it exists in ListA. obviously it returns true because I didn't run a deepcopy... – Azrion Jan 16 '22 at 13:26