KIIT Polytechnic logo Students Hub KIIT Polytechnic ସାଇନ୍ ଇନ୍
▲ବୋର୍ଡ ◆ନୋଟ୍ସ ≡ସିଲାବସ୍ ▦ଟାଇମଟେବଲ୍ ?ସନ୍ଦେହ ▶ରିଲ୍ସ 🎮ଶିଖନ୍ତୁ 🐍କୋର୍ସ ◈ସୁଯୋଗ ✍ବ୍ଲଗ୍ ▮ଷ୍ଟୋର୍ ★ଟିମ୍ ⌕ଖୋଜନ୍ତୁ
← Learn to Code — Python for Beginners ମଡ୍ୟୁଲ୍ · Repeating Yourself

while loops

A for loop repeats a known number of times. A while loop repeats until a condition becomes false — useful when you don't know in advance how many times you'll need to repeat.

count = 0
while count < 5:
    print(count)
    count = count + 1

Be careful: if the condition never becomes false, the loop runs forever (an "infinite loop"). Always make sure something inside the loop eventually changes the condition.