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>Instead of 20 individual arrays you could use a dictionary.</p>

<pre><code>d = {"team1": "someValue",
     "team2": "anotherValue",
     ...
}
</code></pre>

<p>Then you can retrieve the values of a team by its name:</p>

<pre><code>x = raw_input("team1")
</code></pre>

<p><code>d[x]</code> will now return <code>"someValue"</code>. </p>

<p>In your particular case, you can use arrays for the values of the dictionary, for example:</p>

<pre><code>d = {"team1": [value1, value2, ...],
     "team2": [...],          
     ...
}
</code></pre>

<p>Now <code>d[x]</code> returns the array <code>[value1, value2, ...]</code>.</p>

<h2>Complete example</h2>

<p>Finally, you could wrap all of this into a single function f:</p>

<pre><code>def f():
    homeTeam = d[raw_input("Enter home team: ")]
    awayTeam = d[raw_input("Enter away team: ")]
    a = (homeTeam[0] + awayTeam[3])/2
    b = (homeTeam[1] + awayTeam[2])/2
    return a, b
</code></pre>

<p>By calling <code>f()</code> the user will be prompted for two team names. And the function will return the values of both teams in form of a tuple.</p>

python arrays