sdutOJ 查字典(Python)

sdutOJ 查字典(Python),第1张

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!")


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5495670.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-12
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存