Python 3.4.4 How to verify if a string is only made of 0 and 1
<p>I'm doing a binary to decimal converter in python 3.4.4 and it's pretty much finished except for the fact that I would like to check that the binary number entered by the user is indeed a binary number (check if the string is only made of o and 1) but I'm unsure what to do.</p>

<p>here's the program:</p>

<pre><code>binary=input("Enter a binary number") 
bit=len(binary)
result=0
power=0
while bit&gt;0:
    result=result+int(binary[bit-1])*2**power
    bit=bit-1
    power=power+1
print(binary, " in decimal is equal to ", result, sep="")
</code></pre>

<p>hopefully someone can help me &lt;3</p>

<p>Use <code>all()</code></p>

<pre><code> all(x in '10' for x in binary_string) 
</code></pre>

python