Python: Summing Odd/Even Random Numbers Generates TypeError: 'int' object is not iterable
<p>Yes, this question has been asked, but I cannot seem to apply the answers to my problem. There are several parts to this problem, and this is the biggest obstacle I've hit.</p>

<p>I need to generate a random list of 10 numbers between 10 &amp; 90. From those random numbers, I need to sum the totals of both the even and odd numbers.</p>

<pre><code>def playlist():
    nums = []
    for nums in range(10):
        # Get random list of 10 numbers
        my_nums = random.randint(10, 90)
        print (my_nums,end=' ')
        even = []
        odd = []
        for x in my_nums:
            if x % 2 == 0:
                even.append[x]
                print(even)
            else:
                odd.append[x]
                print(odd)
</code></pre>

<p>When I run this, sometimes I get one or two numbers (usually the first two odd numbers), but mostly I get TypeError: 'int' object is not iterable. </p>

<p>Not gonna lie - my first language is PHP, not Python and that's becoming a huge problem for me :(</p>

<p>Any help is appreciated.</p>

<p>You should be doing this.</p>

<pre><code>def playlist():
    nums1 = []
    for nums in range(10):
        # Get random list of 10 numbers
        my_nums = random.randint(10, 90)
        nums1.append(my_nums)
        print my_nums


    even = []
    odd = []
    for x in nums1:
      if x % 2 == 0:
          even.append(x)
          print(even)
      else:
          odd.append(x)
          print(odd)


playlist()
</code></pre>

python random range typeerror iterable