How to access an array using raw_input in python
<p>So, I have a python script which requires an input from the terminal.  I have 20 different arrays and I want to print the array based on the input.</p>

<p>This is the code minus the different arrays.</p>

<pre><code>homeTeam = raw_input()

awayTeam = raw_input()

a = (homeTeam[0])+(awayTeam[3])/2
b = (hometeam[1])+(awayTeam[2])/2
</code></pre>

<p>So, effectively what I want to happen is that homeTeam/awayTeam will take the data of the array that is typed. </p>

<p>Thanks</p>

<p>You may take input as the comma separated (or anything unique you like) string. And call <code>split</code> on that unique identifier to get <code>list</code> (In Python <a href="https://docs.python.org/2/library/array.html" rel="nofollow"><code>array</code></a> and <a href="https://www.tutorialspoint.com/python/python_lists.htm" rel="nofollow"><code>list</code></a> are different).</p>

<p>Below is the example:</p>

<pre><code>&gt;&gt;&gt; my_string = raw_input()
a, b, c, d
&gt;&gt;&gt; my_list = my_string.split(', ')
&gt;&gt;&gt; my_list
['a', 'b', 'c', 'd']
</code></pre>

<p>Since you are having your <code>list</code> now, you already know what you need to do with it.</p>

<p><em>Alternatively</em>, you may also extract list from raw_input by using <a href="https://docs.python.org/2/library/functions.html#eval" rel="nofollow"><code>eval</code></a>. But it is highly recommended not to use eval. Read: <a href="http://stackoverflow.com/questions/1832940/is-using-eval-in-python-a-bad-practice">Is using eval in Python a bad practice?</a></p>

<p>Below is the example:</p>

<pre><code>&gt;&gt;&gt; my_list = eval(raw_input())
[1, 2, 3, 4, 5]
&gt;&gt;&gt; my_list[2]
3
</code></pre>

python arrays