GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — Python While Loop - GeeksforGeeks Python While LoopLast Updated : 5 Oct, 2026 While Loop is used to execute a block of statements repeatedly until a given condition is satisfied. When the condition becomes false, the line immediately after the loop in the program is executed. Here, the condition for while will be True as long as the counter variable (count) is less than 3.
Output Hello Geek Hello Geek Hello Geek Syntax
Parameters:
Flowchart of While Loop![]() Infinite while LoopAn infinite loop is a loop that keeps running continuously because its condition always remains True. Such loops do not stop on their own and continue executing until the program is manually terminated.
Explanation: Here, the condition age > 19 is always True because the value of age never changes inside the loop. Therefore, the loop runs infinitely. Using with continue statementContinue statement is used to skip the current iteration of the loop and move directly to the next iteration.
Output g k f o r g k Explanation: Here, whenever the character is 'e' or 's', the loop skips printing it and continues with the next character. Using with break statementBreak statement is used to immediately terminate the loop when a specific condition becomes True.
Output g Explanation: Here, the loop stops as soon as it encounters the character 'e' or 's'. Using with pass statementpass statement is a null statement. It does nothing when executed and is mainly used as a placeholder for future code.
Output Value of i : 13 Explanation: Here, the loop runs through all characters of the string, but the pass statement performs no action inside the loop body. Using with elseelse block in a while loop executes only when the loop finishes normally without encountering a break statement. In first example, loop completes all iterations, so the else block executes. In second example, loop stops because of break, so the else block is skipped.
Output 1 2 3 4 No Break 1 Comment Explore |
| 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. |