title: Python Try Except when a list is null
body: <p>I've been searching for my problem here, but i can't find the exact answer to my problem.
  I call a sympy function ( solve() ). This function can return a full list or an empty list.
  I call this piece of code inside a while:</p>
  <pre><code>try:
      sol = solve([eq1,eq2],[r,s])
  
      rB = bin(abs(sol[0][0]))
      sB = bin(abs(sol[0][1]))
      stop = True
      r = rB[2:len(rB)]
      s = sB[2:len(sB)]
      P = int(&quot;0b&quot;+r+s,2)
      Q = int(&quot;0b&quot;+s+r,2)
      print(P*Q == pubKey.n)
      print(&quot;P = {}&quot;.format(P))
      print(&quot;Q = {}&quot;.format(Q))
      break
  except ValueError:
      pass
  </code></pre>
  <p>What i want is:
  if the solve() returns an empty list, just pass. And if the solve() returns a full list, keep with the execution. The solve will be returning empty list until i find the right value.
  This can be reached by checking sol[0][0], if there's a non-empty list this will work, but if the list is empty, this will throw an error (null pointer) i want try to flag it and pass.</p>
  <p>What i'm having now is that when sol is empty, it tries to get sol[0][0], and ofc this throws an error that's not being catched by the try, and the whole code stops.
  Anyone knows a solution for that? I'm not using try correctly?</p>