This code creates a loop that asks the user for an input value and continues to do so until the value entered is equal to 3. The input("? ")
function prompts the user to enter a value, and that value is stored in the variable x
. The while ~isempty(x)
line makes sure that the loop continues as long as the x
variable still has a valid value (i.e., is not empty). The if x == 3
line checks if the value entered is equal to 3 and, if so, the break
statement exits the loop. If the value entered is not equal to 3, the loop continues and the user is again prompted for input with x = input("? ")
.
Here is the commented code for the same:
main.m551 chars8 lines
gistlibby LogSnag