title: Linked lists and patterns python
body: <p>Trying to write a function that will iterate over the linked list, sum up all of the odd numbers and then display the sum. Here is what I have so far:</p>
  
  <pre><code>def main():
     array = eval(input("Give me an array of numbers: "))
     ArrayToList(array)
     print(array[0])
     print(array[1])
     print(array[2])
     print(array[3])
     print(sumOdds(array))
  
  
  def isOdd(x):
      return x % 2 != 0
  
  def sumOdds(array):
      if (array == None):
          return 0
      elif (isOdd(head(array))):
          return head(array) + sumOdds(tail(array))
      else:
          return sumOdds(tail(array))
  main()
  </code></pre>
  
  <p>I can't get it to actually print the sum though. Can anybody help me out with that?</p>
  
  <p>Here is the output of the program when I run it:</p>
  
  <pre><code>$ python3 1.py
  Give me an array of numbers: [11, 5, 3, 51]
  Traceback (most recent call last):
    File "1.py", line 22, in &lt;module&gt;
      main()
    File "1.py", line 10, in main
      print(sumOdds(array))
    File "1.py", line 19, in sumOdds
      return head(array) + sumOdds(tail(array))
    File "1.py", line 18, in sumOdds
      elif (isOdd(head(array))):
    File "/Users/~/cs150/practice3/friday/List.py", line 34, in head
      return NodeValue(items)
    File "/Users/~/cs150/practice3/friday/List.py", line 12, in NodeValue
      def NodeValue(n): return n[0]
    TypeError: 'int' object is not subscriptable
  </code></pre>