【发布时间】:2021-12-10 10:13:51
【问题描述】:
我正在学习 python 并且很难使用这段代码。我需要用列表中的元素更新每个 dict 键值。 list 和 dict 将始终具有相同的长度。
list = [1, 2, 3, 4, 5]
dict = {2433: 0, 2429: 0, 2425: 0, 2423: 0, 2427: 0}
预期输出:
dict = {2433: 1, 2429: 2, 2425: 3, 2423: 4, 2427: 5}
【问题讨论】:
标签: python list loops dictionary for-loop