I've got a program with a code lock, and I would like the program to restart when you enter the incorrect code. Does anyone know of a way to do that?

1 Answer 1


If I were you I'd use a loop inside the program. In this loop the prompt for entering the code would be displayed, then the user input would be read. Finally, the code would be checked and if correct, the proper action executed, otherwise a failure message would be shown and the execution would loop back to the start (display the prompt).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.