通过语句在Python中途停止'while'循环的最佳方法是什么?我知道,break但我认为使用这将是不好的做法.
例如,在下面的代码中,我只希望程序打印一次,而不是两次...
variable = ""
while variable == "" :
print("Variable is blank.")
# statement should break here...
variable = "text"
print("Variable is: " + variable)
Run Code Online (Sandbox Code Playgroud)
你能帮我吗?提前致谢.