我有一个包含学生ID和分数的列表。我希望只将分数附加到不同的列表中,但每次我试图只打印第二个元素时,它都会给我整行(学生ID和分数)。我应该怎样做呢?
[['10000', '43\n'],
['10001', '26\n'],
['10002', '43\n'],
['10003', '57\n'],
['10004', '100\n'],
['10005', '57\n'],
['10006', '55\n'],
['10007', '60\n'],
['10008', '37\n'],
['10009', '30\n'],
['10010', '50\n'],
['10011', '17\n'],
['10012', '59\n'],
['10013', '57\n'],
['10014', '27\n'],
['10015', '6\n'],
['10016', '49\n'],
['10017', '30\n'],
['10018', '57\n'],
['10019', '56\n']]
def get_ids(lists):
score_list = list()
for lis in lists:
score = lis[0]
score_list.append(score)
return score_list
list_of_lists = [
["10000", "43\n"],
["10001", "26\n"],
["10002", "43\n"],
["10003", "57\n"],
["10004", "100\n"],
["10005", "57\n"],
["10006", "55\n"],
["10007", "60\n"],
["10008", "37\n"],
["10009", "30\n"],
["10010", "50\n"],
["10011", "17\n"],
["10012", "59\n"],
["10013", "57\n"],
["10014", "27\n"],
["10015", "6\n"],
["10016", "49\n"],
["10017", "30\n"],
["10018", "57\n"],
["10019", "56\n"],
]
print(get_ids(list_of_lists))
做了什么。