title: Normalize lists of numbers for probabilities - Python
body: <p>I am trying to normalize lists of numbers using Python. I am aware of this page <a href="https://stackoverflow.com/questions/26785354/normalizing-a-list-of-numbers-in-python/26785464">Normalizing a list of numbers in Python</a>.</p>
  
  <pre><code>def normalize(lst):
       s = sum(lst)
       return map(lambda x: float(x)/s, lst)
  
  raw = [[0.07, 0.14, 0.07], [0.10, 0.05, 0.05]]
  
  for i in raw:
  print normalize(i)
  </code></pre>
  
  <p>The above codes work just fine. But, my data is in the following format:</p>
  
  <pre><code>raw1 = [['0.07', '0.14', '0.07'], ['0.10', '0.05', '0.05']]
  
  for i in raw1:
       print normalize(i)
  </code></pre>
  
  <p>And, I am getting this error:</p>
  
  <pre><code>TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-39-96ae4b221f63&gt; in &lt;module&gt;()
        1 for i in raw1:
  ----&gt; 2     print normalize(i)
  
  &lt;ipython-input-28-9ad45c58be20&gt; in normalize(lst)
        1 def normalize(lst):
  ----&gt; 2     s = sum(lst)
        3     return map(lambda x: float(x)/s, lst)
  
  TypeError: unsupported operand type(s) for +: 'int' and 'str'
  </code></pre>
  
  <p>Any suggestions?</p>