What is the best way to stop a 'while' loop in Python mid-way through the statement? I'm aware of break
but I thought using this would be bad practice.
For example, in this code below, I only want the program to print once, not twice...
variable = ""
while variable == "" :
print("Variable is blank.")
# statement should break here...
variable = "text"
print("Variable is: " + variable)
Can you help? Thanks in advance.
See Question&Answers more detail:os