Как сделать что бы выбор был не с 0 до 2, а с 1 до 3?
Игра крестики нолики. Нужно что бы выбор строки и столбца был не с 0 до 2, а с 1 до 3. (типо что бы было удобней выбирать)
вот пример:
row = int(input("Введите номер строки(0, 1, 2): "))
column = int(input("Введите номер столбца(0, 1, 2): "))
Код внизу:
import random
def check_winner():
if area[0][0] == "X" and area[0][1] == "X" and area[0][2] == "X":
return "X"
if area[1][0] == "X" and area[1][1] == "X" and area[1][2] == "X":
return "X"
if area[2][0] == "X" and area[2][1] == "X" and area[2][2] == "X":
return "X"
if area[0][0] == "X" and area[1][0] == "X" and area[2][0] == "X":
return "X"
if area[0][1] == "X" and area[1][1] == "X" and area[2][1] == "X":
return "X"
if area[0][2] == "X" and area[1][2] == "X" and area[2][2] == "X":
return "X"
if area[0][0] == "X" and area[1][1] == "X" and area[2][2] == "X":
return "X"
if area[0][2] == "X" and area[1][1] == "X" and area[2][0] == "X":
return "X"
if area[0][0] == "0" and area[0][1] == "0" and area[0][2] == "0":
return "0"
if area[1][0] == "0" and area[1][1] == "0" and area[1][2] == "0":
return "0"
if area[2][0] == "0" and area[2][1] == "0" and area[2][2] == "0":
return "0"
if area[0][0] == "0" and area[1][0] == "0" and area[2][0] == "0":
return "0"
if area[0][1] == "0" and area[1][1] == "0" and area[2][1] == "0":
return "0"
if area[0][2] == "0" and area[1][2] == "0" and area[2][2] == "0":
return "0"
if area[0][0] == "0" and area[1][1] == "0" and area[2][2] == "0":
return "0"
if area[0][2] == "0" and area[1][1] == "0" and area[2][0] == "0":
return "0"
return "*"
def print_area():
for cell in area:
print(cell)
chars = ["0", "X"]
char = random.choice(chars)
print(f"Первые ходят-{char}")
area = [["*", "*", "*"], ["*", "*", "*"], ["*", "*", "*"]]
print_area()
for turn in range(1, 10):
print(f"Ход: {turn}")
row = int(input("Введите номер строки(0, 1, 2): "))
column = int(input("Введите номер столбца(0, 1, 2): "))
if turn % 2 == 0:
turn_char = "0" if char == "X" else "X"
else:
turn_char = char
if area[row][column] == "*":
area[row][column] = turn_char
else:
print("Ячейка занята")
continue
print_area()
if check_winner() == "X":
print("Победили крестики")
break
if check_winner() == "0":
print("Победили нолики")
break
if check_winner() == "*" and turn == 9:
print("Ничья")
def check_winner():
if area[0][0] == "X" and area[0][1] == "X" and area[0][2] == "X":
return "X"
if area[1][0] == "X" and area[1][1] == "X" and area[1][2] == "X":
return "X"
if area[2][0] == "X" and area[2][1] == "X" and area[2][2] == "X":
return "X"
if area[0][0] == "X" and area[1][0] == "X" and area[2][0] == "X":
return "X"
if area[0][1] == "X" and area[1][1] == "X" and area[2][1] == "X":
return "X"
if area[0][2] == "X" and area[1][2] == "X" and area[2][2] == "X":
return "X"
if area[0][0] == "X" and area[1][1] == "X" and area[2][2] == "X":
return "X"
if area[0][2] == "X" and area[1][1] == "X" and area[2][0] == "X":
return "X"
if area[0][0] == "0" and area[0][1] == "0" and area[0][2] == "0":
return "0"
if area[1][0] == "0" and area[1][1] == "0" and area[1][2] == "0":
return "0"
if area[2][0] == "0" and area[2][1] == "0" and area[2][2] == "0":
return "0"
if area[0][0] == "0" and area[1][0] == "0" and area[2][0] == "0":
return "0"
if area[0][1] == "0" and area[1][1] == "0" and area[2][1] == "0":
return "0"
if area[0][2] == "0" and area[1][2] == "0" and area[2][2] == "0":
return "0"
if area[0][0] == "0" and area[1][1] == "0" and area[2][2] == "0":
return "0"
if area[0][2] == "0" and area[1][1] == "0" and area[2][0] == "0":
return "0"
return "*"