Invalid literal for int() with base 10: 'x' error in Python? : <p>I'm working on a program that prompts a user for a number within a range of integers they've entered. If the number they enter is out of range, they're prompted to give another, and if they enter a letter instead they're prompted to change their answer as well. Here is what I've got:</p>

<pre><code>def code_one(d, f):
    s = input('Enter a number between' + str(d) + 'and' + str(f) + ': ')
    s = int(s)
    if int(d) &lt;= s &lt;= int(f):
        return s
    else:
        while s &lt; int(d) or s &gt; int(f):
            s = input(str(s) + 'is out of range. Please try again. ')
            s = int(s)
            if s &lt; int(d) or s &gt; int(f):
                continue
            else:
                return s
        while s.isdigit == False:
            s = input(str(s) + 'is not a number. Please try again.' )
            if s.isdigit == False:
                continue
            else:
                return s
</code></pre>

<p>It works fine up until the line reading "while s.isdigit == False:" and then, if I input a letter instead of a number, I get the error "invalid literal for int() with base 10: 'x'", (the x being whatever letter I happen to enter). What can I do to fix this?</p>
