Hi, imagine I have this situation:
Is this the best way to create a dictionary with two values in the key field? In this case I have IP1 and IP2 which are components of my key.
Is this a good approach? I attempted to use a tuple or list as a key value, but it seems that is not possible.
>>> ip1 = "1.1.1.1" >>> ip2 = "2.2.2.2" >>> ip3 = "3.3.3.3" >>> >>> elements = {ip1+','+ip2:'100'} >>> elements = {ip1+','+ip3:'200'}Question:
Is this the best way to create a dictionary with two values in the key field? In this case I have IP1 and IP2 which are components of my key.
Is this a good approach? I attempted to use a tuple or list as a key value, but it seems that is not possible.
>>> >>> l = [ip1,ip2] >>> elements = {l:'100'} Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unhashable type: 'list' >>>