How do I convert a list to an integer?
<p>This my code:</p>

<pre><code>snumA = random.sample([4,8,3], 1)
snumB = random.sample([7,2,6], 1)
snumC = random.sample([1,5,9], 1)

sgnA = random.choice(['+','-','/','*'])
sgnB = random.choice(['+','-','/','*'])
sgnC = random.choice(['+','-','/','*'])

if sgnA == '-' :
    sum1 = snumA - bnumA
    print 'minus'
if sgnA == '/' :
    sum1 = snumA / bnumA
    print 'divide'
</code></pre>

<p>Whenever I run this code I get an error message telling me that my operands are lists and not integers. I've looked everywhere and  I still don't know what to do. Could I have some help, please?</p>

<p>The problem is: <code>snumA = random.sample([4,8,3], 1)</code> returns a list of one element (for example: [3] ). What you can do instead is:
Either use <code>snumA = random.choice([4,8,3])</code> which returns directly an integer. Or you get hold of the first element of your list with <code>snumA[0]</code> or directly <code>snumA = random.sample([4,8,3], 1)[0]</code></p>

python