TypeError:不可用类型:在检查列表中的项目时在python中使用'list'

时间:2016-02-27 21:53:20

标签: python

 File "C:\Users\sakre\Documents\Dummy.py", line 330, in <module>
    print find_path_to_friend(net, "John", "Ollie")
  File "C:\Users\sakre\Documents\Dummy.py", line 304, in find_path_to_friend
    path = get_path_recursive(network,toTraverseList[0],user_B,path,traversedList,toTraverseList)
  File "C:\Users\sakre\Documents\Dummy.py", line 286, in get_path_recursive
    if destination  in network[current]['connections']:
TypeError: unhashable type: 'list'

我正在尝试检查时间是否在列表中但是它显示的类型错误并且它适用于以下情况

def add_connection(network, user_A, user_B):
    if user_B not in network[user_A]['connections']:
        network[user_A]['connections'].append(user_B)
    return network

0 个答案:

没有答案