【发布时间】:2018-09-10 10:12:52
【问题描述】:
my_dict = {'one': 1, 'two': 2, 'three': 3}
my_keys = ['three', 'one','ten','one']
solutions = []
for key,value in my_dict.items():
found = False
for i in my_keys:
if i in key:
solutions.append(value)
found = True
break
if not found:
solutions.append('Nan')
我得到这个输出:
['南', 1, '南', '南', '南', '南', 3]
但预期的输出是:
输出:['3', '1', 'Nan', '1']
我怎样才能得到预期的输出?
【问题讨论】:
标签: python