I want to make it either print true or false from using variables and lists
<pre><code>    x = 1
    y = ['1','2']
    if x/y[1] == 2:
       print ('true')
    else:
       print ('false')
</code></pre>

<p>But the variable can not be divided by a list and it gives out</p>

<pre><code>    TypeError: unsupported operand type(s) for /: 'int' and 'str'
</code></pre>

<p>Please help. </p>

<p>That's because you're trying to divide a string. Changing your code to convert <code>y</code> into an <code>int</code> will fix your problem.</p>

<pre><code>x = 1
y = ['1','2']
if x/int(y[1]) == 2:
   print ('true')
else:
   print ('false')
</code></pre>

python