So, I need to use a for i in loop on a list that is within a list. Let me give you an example.
I have a blacklist (list) that contains 10 categories (also lists), in those categories, there are always 2 ints.
I also have a list called x. x contains 2 ints.
I want to check if the 2 ints inside x are the same as any of the blacklist categories.
In order to do that I need to do
def blacklist_check(blacklist, z):
for i in blacklist:
for y in blacklist[i]:
difference = blacklist[i][y] - z
if difference < 10 and difference > -10:
print(f"{difference} found")
return False
print(f"{difference} not found")
if i == 10:
return True
but when I try that I get
TypeError: list indices must be integers or slices, not list
I can not transfer the categories to ints or any other type than lists. How do I make this work?
for y in ianddifference = y - z. Note thatiis the element in theblacklist, not their index.