mathematical operations on the contents of a list
<p>I have got a list which is the output of my code and want to carry some more operations in this list. I have written the code to convert the ranges in the input list to a single value with 3 choices. </p>

<pre><code>newlist = [[('s', [(0.0, 0.3), (0.1, 0.8), (0.0, 1.0), (0.0, 0.0), (0.0, 0.5)]), 
            ('aa', [(0.0, 0.3), [0.1, 0.8], (0.0, 1.0), [0.0, 1.0], (0.0, 0.5)])], 
          [('m', [(0.0, 0.0), (0.0, 0.0), (0.1, 0.5), (0.0, 0.8), (0.0, 0.0)]), 
           ('ih', [(0.0, 0.0), (0.1, 0.8), (0.1, 0.5), (0.0, 0.4), (0.0, 0.0)])]] 

e = int(raw_input("\n Choose the energy level of the speaker: \n '1' for low \n '2' for normal \n '3' for high \n"))

if e == 1 :
    pList = [(i[0], [j[0] for j in i[1]]) for i in newlist]

elif e == 2:
    pList = [(i[0], [(float(j[0]) + float(j[1])) / 2.0 for j in i[1]]) for i in newlist]

elif e == 3:
    pList = [(i[0], [j[1] for j in i[1]]) for i in newlist]    

print pList
</code></pre>

<p>with choice 1 the output should be as,</p>

<pre><code>pList = [[('s', [(0.0, 0.1, 0.0, 0.0, 0.0)]), 
          ('aa', [(0.0, 0.1, 0.0, 0.0, 0.0)])], 
        [('m', [(0.0, 0.0, 0.1, 0.0, 0.0)]), 
         ('ih', [(0.0, 0.1, 0.1, 0.0, 0.0)])]]  
</code></pre>

<p>with choice 2 the output should be,</p>

<pre><code>pList = [[('s', [(0.15, 0.45, 0.5, 0.0, 0.25)]), 
          ('aa', [(0.15, 0.45, 0.5, 0.5, 0.25)])], 
        [('m', [0.0, 0.0, 0.3, 0.4, 0.0)]), 
         ('ih', [(0.0, 0.45, 0.3, 0.2, 0.0)])]] 
</code></pre>

<p>and with choice 3 the output should look like,</p>

<pre><code>pList = [[('s', [(0.3, 0.8, 1.0, 0.0, 0.5)]), 
          ('aa', [(0.3, 0.8, 1.0, 1.0, 0.5)])], 
        [('m', [(0.0, 0.0, 0.5, 0.8, 0.0)]), 
         ('ih', [(0.0, 0.8, 0.5, 0.4, 0.0)])]] 
</code></pre>

<p>None of the choices is working. I think I have made mistakes with the indices. Choice 2 gives an error as, </p>

<pre><code>"ValueError: invalid literal for float(): a"
</code></pre>

<p>Thank you.</p>
