1

How to Use the Else Block in For and While Loops in Python

News Discuss 
To create a for loop, we typically iterate over a list. In this example, we will create a for loop that iterates over a range of 10 numbers. Inside the loop, we will check if the current number (i) is equal to 5. If it is, we will print a message stating that the loop was broken and then break out of the loop. https://www.nomidl.com/python/how-to-use-the-else-block-in-python/

Comments

    No HTML

    HTML is disabled


Who Upvoted this Story