There are a bunch of problems with your code, but there are a few big problems here.
First, the else
in while...else
doesn't mean what you think it does. It's not like in if...else
. In while...else
, the else
block is executed if your while
statement becomes False
--note that that does not include if you break
out of the loop or there's an error. In your code, the else
block would be executed when xvalue < Limit
, since that's the opposite of your Boolean expression for the while
.
Second, because the else
block is executed after the loop, putting continue
in there doesn't make any sense, since there's no longer any loop to iterate over. Not only that, even if there were a loop continuing, the fact that you stuck continue
before xvalue = int(input...
means that the loop will be restarted before the user gets a chance to put in an updated value. You would need to put continue
after the reassignment, and at that point, there's no point to putting in the continue
at all.
So basically, what you're looking for is:
xvalue = int(input("Enter a test value to see if it works: "))
while xvalue >= Limit:
print ("\a\a\a")
xvalue = int(input("Please try another value: "))
Updated after OP comments:
xvalue = int(input("Enter a test value to see if it works: "))
while xvalue < Limit: # Repeats until user gives a value above limit
xvalue = int(input("Please try another value: "))
else:
while True: # Causes bell to ring infinitely
print ("\a\a\a")