Access elements of 2D list
<p>I have a list of variables in python and I would like to be able to access the index of individual values in each row and column. Because I am new to python, I do not know if there is another way to access the index or select individual values by row and column.</p>

<p>The only way I have found so far is to use the pandas library, but I cannot use pandas because of a problem in installation. Please advise me on how to create a dataframe(without using pandas) or any other data structure so that I can access its values by their index, by row and column.</p>

<p>Let's say I have the following list: (Actually when I try to find the data structure type, python says it is a list.</p>

<pre><code>(['Name'    'Age'        'Smoking'   'Grade']) 

(['Joh'      23           'No'         90])

(['Zak'      25           'No'         89])

(['Suz'      24           'Yes'        80])

(['Sus'      26           'Yes'        83])
</code></pre>

<p>Let's say we name it "habits"</p>

<p>I would like to access individual values, such as habits[3,2] and I would like to have the result as 80 which is located at the 3rd index of rows and at the 2nd index of columns.</p>

<p>What you want is a list of lists.</p>

<p>This is how you can make one:</p>

<pre><code>data = [[1, 2, 3, 4],
        ['blue', 'green', 'red', 'yellow']]
data.append(['elephant', 'donkey', 'cat'])
</code></pre>

<p>This is how you access its contents:</p>

<pre><code>data[0]  # [1, 2, 3, 4]
data[0][0]  # 1
data[1][2]  # 'red'
</code></pre>

python indexing data-structures