【发布时间】:2015-10-10 13:14:34
【问题描述】:
我正在尝试编写一个程序,将测试分数收集在列表中,然后输出某些因素,例如最高分数。但是,当我尝试分配 intH1(测试 1 的最高结果)时,出现上述错误。该行是intH1 = score1_list[intCount] and strHN1 = name_list[intCount]
if score1_list[intCount] > intH1:
intH1 = score1_list[intCount] and strHN1 = name_list[intCount]
if score2_list[intCount] > intH2:
intH2 = score2_list[intCount] and strHN2 = name_list[intCount]
if score3_list[intCount] > intH3:
intH3 = score3_list[intCount] and strHN3 = name_list[intCount]
if total_list[intCount] > intHT:
intHT = total_list[intCount] and strHNT = name_list[intCount]`
【问题讨论】:
-
您希望
intH1 = score1_list[intCount] and strHN1 = name_list[intCount]实现什么目标?这不是有效的 Python。 -
如果
intH1小于score1_list[intCount],我试图将intH1更改为score1_list[intCount],并将strHN1(学生姓名)更改为name_list[intCount],以便他们可以一起输出说“测试 1 的最高分是 ... 由 ...”。我为我糟糕的代码道歉,我只学了几个星期的 Python。
标签: python arrays syntax-error assign