Python

Python – While Loop

# The while loop executes a suite of code if its condition is True counter = 3 while counter > 0: print("Counting down:", counter) counter -= 1 while counter > 0: print('Never executes suite') print('when condition is False')
names = ['Msd', 'kohli'] while names: print(names.pop(), 'is going')
results = [1, 0, 1] processed = 0 passed = 0 while results: processed += 1 result = results.pop() if not result: continue passed += 1 else: print('Processed:', processed, 'Passed:', passed)

Share This Post

An Ambivert, music lover, enthusiast, artist, designer, coder, gamer, content writer. He is Professional Software Developer with hands-on experience in Spark, Kafka, Scala, Python, Hadoop, Hive, Sqoop, Pig, php, html,css. Know more about him at www.24tutorials.com/sai

Lost Password

Register

24 Tutorials