python for loop after statement code example
Example 1: how to use iteration in python
n = 5
while n > 0:
print n
n = n-1
print 'Blastoff!'
Example 2: python for loop iterator
import numpy as np
# With array cycling
arr = np.array([1,2,3,4,5,6,7,8,9])
for i in range(len(arr)):
# logic with iterator use (current logic replaces even numbers with zero)
if arr[i] % 2 == 0: arr[i] = 0
print(arr)
# Output: [1, 0, 3, 0, 5, 0, 7, 0 , 9]