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, 2280🔥, 0💬
Popular Posts:
How To Read the Entire File into a Single String in PHP? If you have a file, and you want to read th...
How to use 'choose ... when ..." policy statements to control execution flows? If you want to contro...
How to build a PHP script to dump Azure AD 2.0 Authentication Response? If you are use the Azure-AD-...
How to use the "set-variable" Policy Statement to create custom variables for an Azure API service o...
How to use the XML to JSON Conversion Tool at freeformatter.com? If you want to try the XML to JSON ...