我在尝试将输出放入列中时遇到问题。我已经尝试使用%d但我一直得到TypeError:在字符串格式化过程中并非所有参数都被转换。到目前为止我所拥有的:
ids = []
scores = []
grades = []
items = []
id_Test = eval(input("Enter an ID number:"))
while id_Test != 0:
score = eval(input("Enter a score(0.0 - 100.0):"))
ids.append(id_Test)
scores.append(score)
id_Test = eval(input("Enter another ID number:"))
avg_score = sum(scores) / len(scores)
for score in scores:
if score > avg_score + 10:
grades.append('A')
elif score > avg_score + 5:
grades.append('B')
elif score > avg_score - 5:
grades.append('C')
elif score > avg_score - 10:
grades.append('D')
else:
grades.append('F')
print("ID SCORE GRADE")
for item in range(len(ids)):
print('%%%8d' % (ids[item], scores[item], grades[item]))
我一直收到这个TypeError:
Traceback (most recent call last):
File "/Users/Ambriorix/Desktop/$RECYCLE.BIN/LAB3.py", line 40, in <module>
print('%%%8d' % (ids[item], scores[item], grades[item]))
TypeError: not all arguments converted during string formatting