If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
Python में While Loop ठीक वैसे ही काम करते हैं जिस तरह से C या JAVA में करते हैं। While Loop Simply Repeatedly Statements को Execute करता है , जब तक कि दी हुई Condition False न हो। जब तक Condition True है तब तक Loop Execute होगा।
While Loop को Entry Control Loop भी कहते हैं क्योंकि loop को Execute करने से पहले दी हुई condition Check होती है , condition True होने पर ही Loop में Entry होती है।
while condition / expression :
#do whatever you want.
or
while (condition / expression) :
#do whatever you want.
हालाँकि condition को आप parenthesis ( while(condition) ) में रखें या न रखें उससे फर्क नहीं पड़ता है।
while Loop Chart Flow
number = 1
table = 5
while number <= 10 :
print(number, ' * ', table, ' = ', number*table )
number = number + 1
इसके अलावा आप Python में Nested While Loop का भी use कर सकते हैं , means While Loop के अंदर एक और While Loop.
x = 1
while x <= 10 :
y = 1
print(y, end=' ')
while y < x :
y = y+1
print(y, end=' ')
print('')
x = x+1
Note : while loop use करते समय यह ध्यान रखें कि loop को terminate करने के लिए एक valid false condition होनी ही चाहिए otherwise loop endlessly run करता रहेगा जिससे पूरा program crack / hang हो सकता है।
Hi ! My name is Rahul Kumar Rajput. I'm a back end web developer and founder of learnhindituts.com. I live in Uttar Pradesh (UP), India and I love to talk about programming as well as writing technical tutorials and tips that can help to others.
Get connected with me. :) LinkedIn Twitter Instagram Facebook