Я практикую Python, делая игру с подключением четыре, и я застрял в этой ошибке, и я не уверен, какие дальнейшие шаги я должен предпринять, чтобы исправить ее. Файл "main.py", строка 108, в player1 () TypeError: объект 'str' не может быть вызван
import pandas as pd
data = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0,
0, 0], [0, 0, 0, 0 ,0, 0]]
df = pd.DataFrame(data, columns = ['A', 'B', 'C', 'D', 'E', 'F'])
print(df)
a = df['A']
b = df['B']
c = df['C']
d = df['D']
e = df['E']
f = df['F']
player1 = 'H'
player2 = 'X'
for i in range(len(df)):
a_cell = a[i]
b_cell = b[i]
c_cell = c[i]
d_cell = d[i]
e_cell = e[i]
f_cell = f[i]
# Prevents board piece from changing after changed once
if a[i] == 'X' or a[i] == 'H':
a[i] != player1.inputs or player2.inputs
if b[i] == 'X' or b[i] == 'H':
b[i] != player1.inputs or player2.inputs
if c[i] == 'X' or c[i] == 'H':
c[i] != player1.inputs or player2.inputs
if d[i] == 'X' or d[i] == 'H':
d[i] != player1.inputs or player2.inputs
if e[i] == 'X' or e[i] == 'H':
e[i] != player1.inputs or player2.inputs
if f[i] == 'X' or f[i] == 'H':
f[i] != player1.inputs or player2.inputs
# Places board pieces from input
def player1():
if player1 == "a" and a[i] != "X" and a[i] != "H":
a[i] = "H"
print(df)
elif player1 == "b" and b[i] != 'X' and b[i] != 'H':
b[i] = "H"
print(df)
elif player1 == "c" and c[i] != 'X' and b[i] != 'H':
c[i] = "H"
print(df)
elif player1 == "d" and d[i] != 'X' and b[i] != 'H':
d[i] = "H"
print(df)
elif player1 == "e" and e[i] != 'X' and b[i] != 'H':
e[i] = "H"
print(df)
elif player1 == "f" and f[i] != 'X' and b[i] != 'H':
f[i] = "H"
print(df)
else:
player1 = input("Player1, select a correct board piece: ")
player1()
def player2():
if player2 == "a" and a[i] != "X" and a[i] != "H":
a[i] = "X"
print(df)
elif player2 == "b" and b[i] != 'X' and b[i] != 'H':
b[i] = 'X'
print(df)
elif player2 == "c" and c[i] != 'X' and c[i] != 'H':
c[i] = "X"
print(df)
elif player2 == "d" and d[i] != 'X' and d[i] != 'H':
d[i] = "X"
print(df)
elif player2 == "e" and e[i] != 'X' and e[i] != 'H' :
e[i] = "X"
print(df)
elif player2 == "f" and f[i] != 'X' and f[i] != 'H':
f[i] = "X"
print(df)
else:
player2 = input("Player2, select a correct board piece: ")
player2()
player1 = "H"
player2 = "X"
player1 = input("Player1, select board piece: ")
while True:
if player1 == 'a' or player1 == 'b' or player1 == 'c' or player1 == 'd' or player1 == 'e' or
player1 == 'f':
player1()
player2 = input("Player2, select board piece: ")
elif player2 == 'a' or player2 == 'b' or player2 == 'c' or player2 == 'd' or player2 == 'e' or
player2 == 'f':
player2()
player1 = input("Player1, select board piece: ")
В нем также указывается локальная переменная 'player1', определенная в прилагаемой области видимости в строке 114, на которую ссылается перед назначением и есть один для 'player2', но на линии 109