Only accept a float between 0 and 1 - python
<p>So I need a really efficient code which will accept any number between 0 and 1 from the user and keep on prompting them to try again until their input meets this criteria.
This is what I've got so far:</p>
<pre class="lang-py prettyprint-override"><code>def user_input():
    while True:
        global initial_input
        initial_input = input(&quot;Please enter a number between 1 and 0&quot;)
        if initial_input.isnumeric() and (0 &lt;= float(initial_input) &lt;= 1):
            initial_input = float(initial_input)
            return(initial_input)
        print(&quot;Please try again, it must be a number between 0 and 1&quot;)

user_input()
</code></pre>
<p>This works but only if the number is actually 1 or 0. If you input a decimal between these (e.g 0.6), it crashes</p>