2016-10-24 5 views
0

whileループの条件がPythonのループ内で真であるかどうかを確認する方法はありますか?このようなもの:特定のポイントでwhileループを評価しますか?

i = 0 
while i < 2: 
    i = 2 
    evalcond 
    print("This executes because the condition is still true at this point") 

これは可能ですか?

+1

を行うことができますが、 '1しばらくしたいように見える:'と 'の場合:... break'構造を。 – TigerhawkT3

答えて

1

これはおそらく何か?あなたがbreakを使用しないようにしたい場合は

i = 0 
while i < 2: 
    i = 2 
    if i >= 2: 
     break 
    print("This executes because the condition is still true at this point") 
0

あなたもこの

i = 0 
while i < 2: 
    i = 2 
    if i < 2: 
     print("This executes because the condition is still true at this point") 
関連する問題