M is a non-empty matrix (a list of lists) in which every row has the same
length.
Write is_valid_coordinate(x, y, M) that returns True if (x, y) is a valid
pair of indices in M -- that is, M[x][y] exists -- and False otherwise.
x is the row index and y is the column index.
Example
is_valid_coordinate(1, 1, [[1, 0], [0, 1]]) returns True, and
is_valid_coordinate(2, 0, [[1, 0], [0, 1]]) returns False.
Implement this function:
def is_valid_coordinate(x: int, y: int, M) -> bool:
Write the function only — the arguments are read for you and the return value is printed automatically.
Arguments arrive as one Python literal per line, in this order: x, y, M.
Input
0
0
[[1, 0], [0, 1]]
Output
True