I'm trying to write a function that analyzes a given list of lists for a specific position and returns True if the position exists and False if it doesn't.
For example, if the list of lists that we'll call "list2" has 7 columns and 5 rows (Basically a list of 5 lists where each list has 7 values and is on its own line), the function should return True if the test case list2[5][4] is run through the function because row 5, and column 4 exists but if the test case list2[8][6] or list2[-5][-1] is run through the function it should return False because row 8 and column 6 don't exist and we can't have negative rows and columns. How could this be accomplished?
This is the code I have so far. When tested it says invalid syntax but I thought I'd include it anyway to help show what my goal is
def in_list(row, col, list):
if list[row][col] == True
return True
else:
return False