a = [[1, 3, 4],[1, 7, 9]]]
b = [1, 7, 0, 9]
Let's say I have a nested list of a, I want to compare the list of b to the nested list a and return True. Say b has 3 items that matches with one of the lists in a, that would be True. How do I do this?
the prompt was to create a tic tac toe game. List a has all the winning combinations, while list b are all the player input. If input is contains 1, 7, and 9 (as in list b), then the combination is part of the winning combinations (in list a). However, player input could include more than 3 numbers and not in the combination order in list a.
I tried the below:
a = [[1, 3, 4],[1,7,9]]
b = [1, 7, 0, 9]
set(a).issubset(b)
But clearly it did not work.
If you want to check if the all of the contents of a sublist of
aare inb, you can use asetand check the difference.