I can’t get it to actually repeat the while loop.
I’ve tried having it register a true value, or make it continue or break out of the loop. But nothing works.
xvalue = int(input("Enter a test value to test if it works: "))
while xvalue >= Limit:
print("\a\a\a")
else:
continue
xvalue = int(input("Updating Value: "))
Can someone suggest something?
I’ve also written it so that it says:
else:
return True
But that doesn’t work. (I get an error)I just need it to keep repeating the while loop until it becomes true on the first condition. And then rings.
There are a bunch of problems with your code, but there are a few big problems here.
First, the
elseinwhile...elsedoesn’t mean what you think it does. It’s not like inif...else. Inwhile...else, theelseblock is executed if yourwhilestatement becomesFalse–note that that does not include if youbreakout of the loop or there’s an error. In your code, theelseblock would be executed whenxvalue < Limit, since that’s the opposite of your Boolean expression for thewhile.Second, because the
elseblock is executed after the loop, puttingcontinuein 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 stuckcontinuebeforexvalue = 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 putcontinueafter the reassignment, and at that point, there’s no point to putting in thecontinueat all.So basically, what you’re looking for is:
Updated after OP comments: