I have the following matrix and I am trying to replace item {6} or any other.
cells = str(input("cache cache: "))
matrix = """
---------
| {0} {1} {2} |
| {3} {4} {5} |
| {6} {7} {8} |
---------
""".format(*cells)
print(matrix)
coordinates = [
("1", "3"), ("2", "3"), ("3", "3"),
("1", "2"), ("2", "2"), ("3", "2"),
("1", "1"), ("2", "1"), ("3", "1")
]
given_coordinates = input("Enter the coordinates: ").split(", ")
t_given_coordinates = tuple(given_coordinates)
for x in coordinates:
if x == t_given_coordinates:
print(matrix.format(*cells.replace(matrix[6], "X")))
The user is supposed to enter the coordinates that relate to the matrix, for example: The given matrix is given in the first input: X_X_O____ From here, if the user inputs coordinates (1, 1), item {6} from matrix gets replaced by 1 X. I don't know how to proceed further, I'm relatively new to Python and I can't figure out how.