Google News
logo
Python Program to Loop through all elements of an array
In the following example of Python program to loop through all elements of an array :
Program :
arr = [1, 2, 3, 4, 5]

for i in arr:
    print(i)
Output :
1
2
3
4
5
In this program, we create an array `arr` containing five elements. We then use a `for` loop to iterate over all the elements of the array.

The loop variable `i` takes on the value of each element in turn, and we print it to the console using the `print()` function.