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, ∼2479🔥, 0💬
Popular Posts:
How To Merge Cells in a Column? If you want to merge multiple cells vertically in a row, you need to...
How to pull NVIDIA CUDA Docker Image with the "docker image pull nvidia/cuda" command? If you are ru...
What is test testing area for? The testing area is provided to allow visitors to post testing commen...
How to use the "send-one-way-request" Policy statement to call an extra web service for an Azure API...
How To Avoid the Undefined Index Error in PHP? If you don't want your PHP page to give out errors as...