How do you get at a value in a list of lists /replace it with a dictionary value?
<p>I need to get at a value in a list of lists. The list in question is called 'newdetails'. It's contents are below</p>

<pre><code>[['12345670', 'Iphone 9.0', '500', '5', '3', '5'], ['12121212', 'Samsung Laptop', '900', '5', '3', '5']]
</code></pre>

<p>I found that print(newdetails[0]) prints the entire first list. What I need however, is to get at index[0] of the first list which is 12345670. I also need to replace index 03 (of both lists) with the VALUE in a dictionary, which corresponds to the first GTIN number.</p>

<p>the code I have so far is:</p>

<pre><code>for gtin,currentstock in dictionary.items():
        if newdetails[0]==gtin:
            newdetails[3]=currentstock
    print("checking to see what newdetails[0] and [3] and [9] is")
    print(newdetails[0])
    print("or is it a matrix or a 2d array")
    print(newdetails[0,3])
    print("now will this work...print replacement list")
    print(newdetails)
</code></pre>

<p>Can someone help?</p>

<p>UPDATE:</p>

<p>Thank you for your suggestion. 
I tried this: (but it came up with an error)</p>

<pre><code>for sub_list in newdetails:
        sub_list[3] = dictionary(sub_list[3], sub_list[3])
    print("sublist")
    print(sub_list)
</code></pre>

<p>Error:
        sub_list[3] = dictionary(sub_list[3], sub_list[3])
        TypeError: 'dict' object is not callable</p>

<p>To clarify, the list i have is called 'newdetails' - and it has two lists inside it (read in from a file).
The name of the dictionary is simply dictionary (for now), and it has a GTIN key and a 'currentstock' VALUE. I want the GTIN key in the dictionary that corresponds with the same GTIN value in BOTH lists to update index 3 (currently showing as 5),. with the value 'currentstock' in the dictionary, that corresponds to the GTIN number.</p>

<p>Thanks in advance to the helpful genius who can help me solve this!</p>

<p>For multidimensional arrays use <a href="http://www.numpy.org/" rel="nofollow">numpy</a> library.</p>

<p>In python, simply use nested lists indexing:</p>

<pre><code>&gt;&gt;&gt; x = [['12345670', 'Iphone 9.0', '500', '5', '3', '5'], ['12121212', 'Samsung Laptop', '900', '5', '3', '5']]
&gt;&gt;&gt; x[0]
['12345670', 'Iphone 9.0', '500', '5', '3', '5']
&gt;&gt;&gt; x[0][0]
'12345670'
&gt;&gt;&gt; x[0][3] = '600'
&gt;&gt;&gt; x[0][3]
'600'
</code></pre>

python list dictionary