InterviewSolution
Saved Bookmarks
| 1. |
Loop Statements in Python |
|
Answer» Loops in Python are statements that allow us to perform a certain operation multiple times unless some condition is met. For Loops: For loop is used to iterate iterables like string, tuple, list, etc and perform some operation as shown in the flowchart below:
print(i) Output: 0 1 2 3 4
This will run the loop from start to stop - 1, with step size = step in each iteration. print(i) Output: 2 4 6 8
for ele in a: print(ele) Output: 1 3 5 7
>>> while count > 0: ... print(count) ... count -= 1 ... 5 4 3 2 1 |
|