我很新手,既不懂编程也不懂Python。几次尝试后,我感觉自己的程序流程有些令人不舒服,想知道是否遵循最佳实践。下面是我的想法:
def pseudocode():
while some condition is true:
do some stuff
if a condition is met:
break out of the while loop
now do a thing once, but only if you never broke out of the loop above
我最终做的东西虽然可行,但总感觉有些不对劲:
def pseudocode():
while some condition is true:
do some stuff
if some condition is met:
some_condition_met = True
break out of the while loop
if some_condition_met is False:
do a thing
有更好的方法吗?