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, ∼2544🔥, 0💬
Popular Posts:
What Is Azure API Management Service? Azure API Management as a turnkey solution for publishing APIs...
Where to find tutorials on RSS specifications? I want to learn it to describe my API services. Here ...
How to detect errors occurred in the json_decode() call? You can use the following two functions to ...
Where can I download the EPUB 2.0 sample book "The Metamorphosis" by Franz Kafka? You can following ...
Tools, FAQ, Tutorials: JSON Validator JSON-XML Converter XML-JSON Converter JSON FAQ/Tutorials Pytho...