While loops iterate based on a condition; for loops iterate a set number of times.
While loops continue until a condition is false, making them useful when the number of iterations isn't known beforehand. For example, in an e-commerce checkout, a while loop might continue adding items to a cart until the cart is full.