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>This is ultimately what I needed:</p>

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


even = []
odd = []
for x in nums:
  if x % 2 == 0:
      even.append(x)
  else:
      odd.append(x)
print ("\n")
print("Total of Even Numbers: ",sum(even))
print ("\n")
print("Total of Odd Numbers: ",sum(odd))
</code></pre>

<p>Thanks to everyone for their help...yes I know the call to run the function is missing - like I said this is just one part of the program :)</p>

python random range typeerror iterable