GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.tutorialsteacher.com — All about for Loops in Python Python for LoopsIn Python, the for loop is used for iterating over sequence types such as list, tuple, set, The body of the Syntax: for x in sequence: statement1 statement2 ... statementN To start with, a variable The following example demonstrates the for loop with the list object. Output The following demonstrates the for loop with a tuple object. Output The object of any Python sequence data type can be iterated using the for statement. Output The following Example: For Loop with Dictionary Output The key-value paris can be unpacked into two variables in the Example: For Loop with Dictionary Output For Loop with the range() FunctionThe Output Exit the For LoopThe execution of the for loop can be stop and exit using the Output Continue Next IterationUse the Output For Loop with Else BlockThe Output Nested for LoopIf a loop (for loop or while loop) contains another loop in its body block, we say that the two loops are nested. If the outer loop is designed to perform m iterations and the inner loop is designed to perform n repetitions, the body block of the inner loop will get executed m X n times. Example: Nested for loop Output |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |