python for in array code example
Example 1: for element in array python
itemlist = []
for j in range(len(myarray)):
item = myarray[j]
itemlist.append(item)
Example 2: python for loop in array
for i in foo:
print(i) #outputs 'foo' then 'bar'
Example 3: iterate through an array python
colors = ["red", "green", "blue", "purple"]
i = 0
while i < len(colors):
print(colors[i])
i += 1
Example 4: python array
array = ["1st", "2nd", "3rd"];
#prints: ['1st', '2nd', '3rd']
Example 5: array in array python
#You can put multiple arrays in one array
tests = [[1,2,3],["r",22,33]]
#prints: [[1,2,3],['r',22,33]]