Laser Locker

5. Check Robot

When dealing with apps that log users in, sometimes we need to focus on security measures to make sure the user is who they say they are. One way of doing this is verifying that a human and not a machine is the one logging into the account. I am sure you have experienced this before. For this step we will ask the user to enter in a series of numbers to validate they are a human. If they input the numbers incorrectly, we will just ask them over and over again until they finally get it correct.

The Variable
For starters we need to add another global variable named robot to the top of our program. This variable should be declared and initialized with the value of 0.

The Loop
Next we need to look at where we send the user to screen 2. Before we send them, we want to check if the user is a robot or not. To do this we will use a loop to check whether or not the variable robot is equal to the number 46382. If it is not, then we should ask the user over and over again to enter in the number 46382; once they enter it correctly, then we can move on to screen 2. Otherwise we will just keep asking.

Remember that a for loop loops for a certain number of times, and a while loop runs while a condition is true.