【发布时间】:2016-01-11 18:26:06
【问题描述】:
我正在尝试拆分一个字符串,然后从该字符串中获取一个关键字并在字典中找到它。然后我想调出字典的那一部分,但我遇到了这个错误-
TypeError: unhashable type:set
- 在最后一行:
solutions = {'display': 'take it to a specialist to get fixed','screen':'test'}
problems = ['display','screen','cracked','broken','clear']``
words = ()
query = input("What is the problem? ")
query_split = query.split()
words = query_split
keyword = set(words) & set(problems)
print(keyword)
print (solutions[keyword])
【问题讨论】:
标签: python list dictionary set typeerror