From 48992d2f660f9551bf267f1f47a1f66d506931ad Mon Sep 17 00:00:00 2001 From: Akanksha10029 Date: Tue, 24 Oct 2023 18:55:24 +0530 Subject: [PATCH] improved logic and added user-friendliness msg for the user The changes include providing a prompt and adding a check for invalid input --- tic_tac_toe(str row to index).py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tic_tac_toe(str row to index).py b/tic_tac_toe(str row to index).py index e649ae0..6629cc3 100644 --- a/tic_tac_toe(str row to index).py +++ b/tic_tac_toe(str row to index).py @@ -26,7 +26,14 @@ "B":1, "C":2 } -def get_row_col(S): - return ( int(S[1])-1 , col_dict[S[0]] ) - -print(get_row_col("C1")) \ No newline at end of file +def get_row_col(s): + return (int(s[1]) - 1, col_dict.get(s[0], -1)) + +cell = input("Enter a cell identifier (e.g., A3) to get the corresponding (row, column) coordinates: ").upper() + +coordinates = get_row_col(cell) + +if coordinates[1] == -1: + print("Invalid input. Please enter a valid cell identifier.") +else: + print(f"The coordinates for {cell} are: {coordinates}") \ No newline at end of file