jyoti690sa...@gmail.com wrote: > Hello, > > Can any one tell me how to create > graph={ > "nodes": [ > { > "id": "n0", > "label": "A node", > "x": 0, > "y": 0, > "size": 3 > }, > { > "id": "n1", > "label": "Another node", > "x": 3, > "y": 1, > "size": 2 > }, > { > "id": "n2", > "label": "And a last one", > "x": 1, > "y": 3, > "size": 1 > } > ], > "edges": [ > { > "id": "e0", > "source": "n0", > "target": "n1", > "label" : "dfghujikoi" > }, > { > "id": "e1", > "label" : "dfghujikoi", > "source": "n1", > "target": "n2" > > }, > { > "id": "e2", > "source": "n2", > "target": "n0", > "label" : "dfghujikoi" > } > ] > } > > using python? > > its like a hash table and value is an array of hash table ? > I tried but it was giving error of "List out of index" .
(1) Was that something like >>> [][1] Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: list index out of range ? Please always copy and paste the traceback, don't rephrase. (2) Show us the code that caused the error. If you provide some context it is easier for us to identify your problem. But if I were to guess: are you coming from a language where lists grow automatically? In Python they don't. Instead of mylist = [] for i in range(3): mylist[i] = 42 # WRONG, raises IndexError you usually write mylist = [] for i in range(3): mylist.append(42) though in this particular case mylist = [42] * 3 would work, too. -- https://mail.python.org/mailman/listinfo/python-list