When the condition is tested and the result is false, the loop body will be skipped and the first statement after the while loop will be executed. One key thing to be noted is that the while loop is entry controlled, which means the loop can never run and the while loop is skipped if the initial test returns FALSE.. For example, following code inside the while loop will be never executed because the initial test will return FALSE.. i = 5 while (i > 8): print ('This is while loop') i++ Unlike Sets, lists in Python are ordered and have a definite count. The while loop tells the computer to do something as long as the condition is met. rev 2021.1.8.38287, Stack Overflow works best with JavaScript enabled, Where developers & technologists share private knowledge with coworkers, Programming & related technical career opportunities, Recruit tech talent & build your employer brand, Reach developers & technologists worldwide, Full function is below. 1. Otherwise, the loop will execute forever, creating an infinite/endless loop. In Python, an empty list can be created by just writing square brackets i.e. Output: 1 3 5 7 9. Both the while loop and range-of … How to use "For Loop" In Python, "for loops" are called iterators. How many presidents had decided not to attend the inauguration of their successor? How to make a flat list out of list of lists? The code within the loop, i.e. Its construct consists of a block of code and a condition. Example. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. Nested Loops. You can safely implement an infinite loop in your program using a break statement. Using loops in computer programming allows us to automate and repeat similar tasks multiple times. With the while loop we can execute a set of statements as long as a condition is true. Using Python! In Python, the list is an array-like data structure which is dynamic in size. In Python, there is no C style for loop, i.e., for (i=0; i