Given an array called array
, loop through all of its elements and print them out.
I have tried to use the following code but it is giving me the error TypeError: list indices must be integers, not str
:
for element in array:
print(array[element])
I have found the article Accessing the index in 'for' loops and I've tried to implement it like so:
for element, x in enumerate(array):
print(array[element])
This still does not print what I was searching for.