save input() into the variable(python)
<p>Here is my code:</p>

<pre><code>def chose_range():
    while True:
        choice = int(input("Choose the range 100 or 1000:"))
        if choice == 100:
            n = 100
            break
        elif choice == 1000:
            n = 1000
            break
        else:
            print('Error, enter the right number')

        return n
</code></pre>

<p>I want to save result of this command into the variable.
How can I do this in python 3?</p>

<p>If you mean "save the result of calling <code>chose_range()</code> into a variable (you didn't say which), then:</p>

<pre><code>theVariable = chose_range()
</code></pre>

<p>However, note that your function does not always return a value to be saved; if it hits a <code>break</code> statement, it exits the loop without executing the <code>return</code> statement, at least in how your posted code is indented.</p>

python user-input