while True: in Python

While True, is a while loop that will loop forever as the evaluated condition is always met, always True.

Try this code below:

secret_code=521
while True:
x=int(input(“input a number= “))

if (x!=secret_code):
print (“This is not the right code”)
elif(x==secret_code):
print(“ok”)
break

Leave a comment