while and for are both flow control statements.
for loops are used when we know the number of iterations, while loops are used when number of iterations are unknown, while loop ends when some condition is met.
for loops are easier to read and also easier to understand as compared to while loops.
for num in range(5):
print (num)
Output
0
1
2
3
4
num = 0
while num <= 5:
print (num)
num = num + 1
Output
0
1
2
3
4
5
In case of while loops some condition must be met, else it will result in an infinite loop.