Difference Between For Loop & While Loop | Learn in 60 Seconds! #loop #forloop #whileloop #coding

preview_player
Показать описание
Understanding Loops: For Loop vs While Loop

Let's start with A Dosa Story

My brother and I went out for dosa one evening.
He confidently ordered 3 dosas upfront, knowing exactly how many he wanted.
I, on the other hand, ordered one at a time, eating and then deciding if I wanted another — until I, too, stopped at 3.

Now, let’s map this to coding logic:
➡️ My brother is a For Loop.
He knew the count already and repeated the action (eating dosa) for a set number of times.
It was structured, controlled, and predictable.

➡️ I represent a While Loop.
I didn’t decide the limit at the beginning. I kept going while I was hungry — the stopping condition was dynamic.
The process depended on checking a condition after each round (each dosa).

This simple dosa experience perfectly illustrates the key difference:
🔹 For Loop: Used when you know in advance how many times to repeat.
🔹 While Loop: Used when repetition depends on a condition being true.

Both loops are essential, just like both of us needed 3 dosas — but the approach was different!

Programming concepts become easier when we relate them to real-life stories.
This is how we teach at Error Makes Clever — through logic, simplicity, and everyday analogies.

💡 Follow us for more relatable coding concepts and tech insights!To know more watch the full video & Stay tuned here for the tech insights

#coding #forloop #whileloop #loop #code
Рекомендации по теме
Комментарии
Автор

Yaaru nee romba easy ah Puriya vachiteenga . Thank you bro .

nirms
Автор

For loop is definite loop, used for achieving certain quantity of loops, example loops for 3 times or 5 times.
While is a indefinite loop, loop will only stop declared condition is achieved, example - loop stops when a=Black colour ( when black colour is achieved, loop stops, no matter the loop quantity).
Do-while loop, used for performing atleast one loop during iteration.
Do-while loop is fancy and used in app onboarding and ending or re onboarding

Aravinthsilva
Автор

For& while-entry check loop
Do while-exit check loop

SIVANANTHANKumar
Автор

For loop used for number of iteration can be performed will be defined And while loop makes the loop runs to satisfy the condition given (it's my type of understanding)

asusgaming
Автор

For loops provide concise iteration over sequences.
While loops offer flexibility for dynamic conditions.
Having both improves code readability and efficiency.
It allows developers to choose the most suitable loop.

joyboymdl
Автор

Both for and while loops can do the same task, but the syntax and use-case make them different.
[one is for counting, the other is for conditions]
#for loop
for i in range(1, 6):
print(i)
#while
i = 1
while i <= 5:
print(i)
i += 1

EvilOne-
Автор

For loop is controlled statement (we can control numbers of loop ) but while loop is a loop that can run infinite loop when condition met it will stop otherwise it is uncomfortable

dineshsrinivasan
Автор

FOR loop: we know how many times the loop should run
While loop: loop runs until certain condition is true(until hunger goes away is the condition here)

Rakshanaramesh-rs
Автор

for loop condition will be checked initially, in while loop the condition will checked finally

bharathtechie
Автор

For loop the condition can be implied at least of one time if the condition is not satisfied and while loop is implied if the condition is satisfied

MeenakshiMeena-nw
Автор

Any decision making program can be used in while loop for putting more no of inputs until breaking the statement under a condition

natarajadithya
Автор

John anna, front end developer la javascript and html thavira mathathulam video podunga anna

SowndaryaNi
Автор

bro machine learning algorithms patti sollunga bro
explain one by one

Anbu-fp
Автор

Because for loop can kept perticular range but while loop can run default meet it can be break the loop

SathyaT-lvmm
Автор

In for loop iteration, initialisation, updation are defined in kya single line but not in while loop we need to define it in three steps

TharunN-cjto
Автор

Access card while loop if the employee has the access and granted the door will open will not open

karthishj
Автор

😂3 dosa - for loop sekirama potu eduthutu vanthuruvanga😅
Ana oru oru dosa - while loop late panuvanga performance ku kaga tha bro 😅 😊

mohankrishnann
Автор

Then why 2 loops bro.tell the fact bro

Thunderboy
Автор

Bro dotnet programming tutorial poduga bro

arunediting
Автор

I started learning python coding
Thanks your video❤❤

arokiaking
welcome to shbcf.ru