Python Tutorial-While Loop

A While Loop is similar to a For Loop in that they both loop through a function or program a given number of times. Usually you have a declared variable followed by the condition for the While Loop, the action you want the program to perform and finally the variable is incremented. Let’s take a look…

Your output should have been 0, 1, 2, 3, 4. It did not print 5 because our condition (While Loop) says while xyz is less than 5. 5 is not less than 5. Very similar to the For Loop, right? Later on we will get into the differences. This is a good starting point for While Loops.

Until next time