sdutOJ 查字典(Python)
作者:互联网
思路:读入时按冒号split之后填成字典即可。
#sdut 查字典
while True:
dic = {}
n,m = input("").split(' ')
n = int(n)
m = int(m)
if n==0 and m==0:
break
for i in range(n):
item = input("").split(':')
key = item[0]
value = item[1].strip()
dic[key] = value
for i in range(m):
word = input("")
if word in dic:
print(dic[word])
else:
print("Not found!")
标签:word,sdutOJ,Python,dic,item,查字典,split,input 来源: https://blog.csdn.net/weixin_43721423/article/details/121327966