g = 1;condition = True #condition may substituted with any argument, and doesn't have to be defined out of the while statement.
while g == 1: #g == 1 is True, therefore it runs the while loop.
if condition: g=2 # g==1 is now False, therefore it breaks out of the while loop
Or using "break", it will produce identical results.
g = 1;condition = True
while g == 1:
if condition: break
Can you quote the exact error that is raised?
from math import ceil
import sys
print("code??"
lengthnumber =input(""
incorrectnumber="0000000"
if lengthnumber==incorrectnumber:
sys.trackbacklimit=0
print("incorrect"
else:
print("code correct"
print(lengthnumber)
from math import ceil
import sys
print("code??"
lengthnumber =input(""
incorrectnumber="0000000"
if lengthnumber==incorrectnumber:
sys.trackbacklimit=0
print("incorrect"
else:
print("code correct"
print(lengthnumber)
1.
Creating a variable with your value (ie. 0000000)
2.
Creating a while loop that checks if the variable is equal to "0000000"
3.
Setting the variable to a user's input.
4.
Handling the printing of the terms "Incorrect", or "Correct" with if/else statements.
Last reply 2 days ago
went from 3s to 9s with (literally) night before revision - ask me anything59
Last reply 2 days ago
went from 3s to 9s with (literally) night before revision - ask me anything59