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>Do not return within your while-loop you break (you have one indent to much).</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
x = chose_range()
</code></pre>

python user-input