user
What is the main difference between a while loop and a for loop?


assistant
The main difference between a while loop and a for loop is that a while loop evaluates a condition before executing the loop body, whereas a for loop assigns initial values for the loop variables and then proceeds to execute the loop body.