Answers for "python for length of array loop"

5

python for loop with array

foo = ['foo', 'bar']
for i in foo:
  print(i) #outputs 'foo' then 'bar'
for i in range(len(foo)):
  print(foo[i]) #outputs 'foo' then 'bar'
i = 0
while i < len(foo):
  print(foo[i]) #outputs 'foo' then 'bar'
Posted by: Guest on July-18-2020
7

for loop with index python3

colors = ["red", "green", "blue", "purple"]

for i in range(len(colors)):
    print(colors[i])
Posted by: Guest on January-28-2020

Code answers related to "python for length of array loop"

Python Answers by Framework

Browse Popular Code Answers by Language