▲ 87 r/learnprogramming
What is the actual difference between a for loop and a while loop?
please don't judge me, I'm a complete beginner. I've been googling this for a while and I think I kind of get it but I'm not sure.
from what I understand a for loop is when you already know how many times you want to repeat something, and a while loop is when you keep going until a condition is false. But then I tried writing both and got the same result which confused me a lot:
```python
for i in range(5):
print(i)
i = 0
while i < 5:
print(i)
i += 1
```
u/Sofiatheneophyte — 1 day ago