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>Change to :</p>

<pre><code>snumA = random.choice([4,8,3])
</code></pre>

<p>which will give you an <code>int</code> instead of a <code>list</code>. To understand better the error here is that you try to use lists (cause <code>random.sample</code> returns a list type result) as integers to make arithmetic operations which is false.
On the other hand <code>random.choice</code> does what you want but returns an <code>int</code>
type result - so you won't get an error.</p>

python