源自:7-1 什么是dict
for name in names: score = scores[index] print('name = {}, score = {}'.format(name, score)) index = index + 1
看不懂,请问大神
提问者:qq_慕哥4392919
2021-11-02 11:24
个回答
-
#这是for循环将names中的值逐个赋给name
for name in names:
#将scores中第index-1个的值取出来存入score
score = scores[index]
#把format函数中的值按先后顺序放入{}中
print('name = {}, score = {}'.format(name, score))
#自增
index = index + 1