Lists and the While loop: Movie Line

 

 

Uses of the ‘while’ loop instruction, which will loop for as long as the loop condition is true.  In this animation, a line of movie goers (implemented with a list), stand in line to get tickets.  After purchasing, the first person walks away and the remaining folks move forward until there are no people left in the line.

 

Demo

 

Code