A for loop repeats over items that are known in advance. A while loop repeats as long as a condition stays true, which suits the cases where you cannot say how many times it will take: waiting for input, searching, retrying. Three small statements, break, continue and pass, steer a loop from inside.
More lessons in Complete Python Programming