我有这段代码:
for k in range(0,player_competition[0]):
max_player=player_name[i][k]
score=0
for m in range(0,player_competition[1]):
if real_scores[m][0]=='?' or real_scores[m][1]=='?':
prediction_real_difference.append(['?','?'])
else:
prediction_real_difference.append( [abs(x-y) for (x,y) in zip(competition_prediction[k*player_competition[1]+m],real_scores[m])] )
if prediction_real_difference[k*player_competition[1]+m][0]=='?' or prediction_real_difference[k*player_competition[1]+m][1]=='?':
score+=0
else:
if competition_prediction[k*player_competition[1]+m][0]>competition_prediction[k*player_competition[1]+m][1] and real_scores[m][0]>real_scores[m][1]:
score+=10
if competition_prediction[k*player_competition[1]+m][0]<competition_prediction[k*player_competition[1]+m][1] and real_scores[m][0]<real_scores[m][1]:
score+=10
if prediction_real_difference[k*player_competition[1]+m][0]<5:
score+= (5-prediction_real_difference[k*player_competition[1]+m][0])
if prediction_real_difference[k*player_competition[1]+m][1]<5:
score+= (5-prediction_real_difference[k*player_competition[1]+m][1])
if score_difference[k*player_competition[1]+m]-real_score_difference[m] < 5 :
score+= (5 - (score_difference[k*player_competition[1]+m]-real_score_difference[m]))
final_scores[player_name[i][k]]=score
if score > max_score:
max_score=score and max_player=player_name[i][k]
print(max_player)
现在它给了我以下错误:
File "prediction_game.py", line 58
maxScore=score and max_player=player_name[i][k]
^
SyntaxError: can't assign to operator
答案 0 :(得分:0)
and
是你的问题,这不是可行的Python代码。
In [1]: foo=42 and bar=42
File "<ipython-input-1-98e4055570ec>", line 1
foo=42 and bar=42
SyntaxError: can't assign to operator
更具体地说,您似乎使用and
作为控制流操作符 - 这是Ruby(例如)中的一个功能,但不是Python中的功能。