Suppose I have a list like this lst = [[0,1,5,0], [4,0,0,7], [0,11]].
I want to create a dictionary, where the key is a tuple (i, j) and the value is lst[i][j]. It should show something like this d = {(0,0): 0, (0, 1): 1, (0,2): 5, (0,3): 0 ... (2,1): 11} I believe you got the pattern now. My attempt to produce something like this goes as fellows:
def convert(lst):
d = dict()
for i in range(len(lst)):
for j in range(i):
d(i, j)] = lst[i][j]
return d
Which doesn't work. It doesn't sweep through the whole list. Kindly help me find the problem with my humble code.