Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions tic_tac_toe(str row to index).py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
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}")