Tools, FAQ, Tutorials:
'while ... else' Repeating Statement Blocks
How to enter "while ... else" statement blocks in Python code?
✍: FYIcenter.com
"while ... else" statement blocks allow you to execute the main statement block repeatedly.
When "while ... else" statement blocks are interpreted, the "while" statement block will be executed repeatedly until the given condition returns False. Then, the "else" statement block is executed once.
"while ... else" statement blocks can be entered in Python code using the following syntax:
while condition:
statement-block
else :
statement-block
For example:
>>> sum = 0
>>> count = 1
>>> while count <= 10:
... sum = sum + count
... count = count + 1
... else:
... print("Sum: "+str(sum))
... print("Count: "+str(count))
...
Sum: 55
Count: 11
⇒ 'break' Statement in Repeating Statement Blocks
⇐ 'for ... in' Statement with List of Tuples
2018-02-28, ∼2396🔥, 0💬
Popular Posts:
Where to find tutorials on OpenID? Here is a large collection of tutorials to answer many frequently...
How to install "The Windows SDK version 8.1"? I need to build my Visual Studio C++ applications. If ...
How to convert JSON Objects to PHP Associative Arrays using the json_decode() function? Actually, JS...
How To Remove Slashes on Submitted Input Values in PHP? By default, when input values are submitted ...
How To Get the Minimum or Maximum Value of an Array in PHP? If you want to get the minimum or maximu...