【发布时间】:2021-02-24 14:36:07
【问题描述】:
我无法准确查询,但这是我想要遍历列表并找到元素值并将结果存储在列表中的参考。
# dict and list are already given to us, we need to iterate over list and check for the elements as key and append the values in a list.
dict = {"a":"apple", "b":"ball"}
list = ["a", "a", "b"]
#output need to be like:
["apple","apple","ball"]
【问题讨论】:
-
避免命名变量
dict和list,因为它们是内置的
标签: python list loops dictionary