title: Using numpy. binary_repr on array of numbers or alternatives - Python
body: <p><strong>using the following code i am trying to convert a list of numbers into binary number but getting an error</strong></p>
  
  <pre><code>import numpy as np
  
  lis=np.array([1,2,3,4,5,6,7,8,9])
  a=np.binary_repr(lis,width=32)
  </code></pre>
  
  <p>the error after running the program is </p>
  
  <blockquote>
    <p>Traceback (most recent call last):</p>
    
    <p>File "", line 4, in 
        a=np.binary_repr(lis,width=32)</p>
    
    <p>File "C:\Users.......",
    in binary_repr
        if num == 0:</p>
    
    <p>ValueError: The truth value of an array with more than one element is
    ambiguous. Use a.any() or a.all()</p>
  </blockquote>
  
  <p><strong>any way to fix this?</strong> </p>