Photo AI
Question 13
A programmer is writing a game. The game uses a 3 x 3 grid containing nine squares. In the game, a square on the grid is referred to by a letter and a number. For e... show full transcript
Step 1
Answer
check = False
while not check:
square = ""
while len(square) != 2:
square = input("Enter grid reference (eg C2): ")
square = square.upper()
row = square[1]
column = square[0]
if column not in ['A', 'B', 'C']:
print("Invalid column reference. Please use 'A', 'B', or 'C'.")
elif row not in ['1', '2', '3']:
print("Invalid row reference. Please use '1', '2', or '3'.")
else:
check = True # Valid input
print(f"You have entered a valid grid reference: {square}")
Report Improved Results
Recommend to friends
Students Supported
Questions answered