我有一个大字典,我正在搜索它以找到一个特定的字符串。字典的键是数字,然后值是元组。我将如何创建一个函数来使用不区分大小写的搜索遍历字典,然后获取包含相关短语的键,并将它们添加到新列表中?我想在我创建的后续函数(显示)中使用这个新列表 [匹配] 来打印信息。
我的代码如下所示:
dict = {
1 : (value,value,value),
2 : (value,value,value),
so on...
}
# searches dict, criteria determines whether search is for str() or int(), phrase is string I am searching for
def search(criteria,phrase):
enter code here
# prints new list
def show(match):