Python doesn't have arrays like in C++ or Java. Instead you can use a list.

my_list = ['hello','hi','hurra']

for text in my_list:
    print(text)

There are multiple ways to iterate the list, e.g.:

for i, text in enumerate(my_list):
    print(i, text)

for i in range(0, len(my_list)):
    print(my_list[i])

You could use it like "arrays", but there are many build-in functions that you would find very useful. This is a basic and essential data structure in Python. Most of books or tutorials would cover this topic in the first few chapters.

P.S.: The codes are for Python 3.

Answer from ioannu on Stack Overflow
๐ŸŒ
Linux Hint
linuxhint.com โ€บ iterate-string-array-python
How do I iterate through a string array in Python?
August 18, 2021 - Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
People also ask

Can a 'for loop' in Python be nested within another 'for loop'?
Yes, a 'for loop' in Python can be nested within another 'for loop'. This allows iterating over multiple sequences or creating multi-dimensional iterations, such as traversing through a matrix or a list of lists.
๐ŸŒ
studysmarter.co.uk
studysmarter.co.uk โ€บ for loop in python
for Loop in Python: Syntax & Range | StudySmarter
How can I iterate over a list using a 'for loop' in Python?
You can iterate over a list in Python using a 'for loop' by writing `for item in list:`, where `item` represents each element in the list. This loop will execute a block of code for each element.
๐ŸŒ
studysmarter.co.uk
studysmarter.co.uk โ€บ for loop in python
for Loop in Python: Syntax & Range | StudySmarter
How do I use a 'for loop' to iterate over a dictionary in Python?
You can iterate over a dictionary in Python using a 'for loop' by using the items() method to get key-value pairs, or directly iterate to get keys. For example, `for key, value in dict.items():` to access keys and values, or `for key in dict:` to access just keys.
๐ŸŒ
studysmarter.co.uk
studysmarter.co.uk โ€บ for loop in python
for Loop in Python: Syntax & Range | StudySmarter
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ gloss_python_array_loop.asp
Python Loop Through an Array
Remove List Duplicates Reverse a String Add Two Numbers ยท Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... You can use the for in loop to loop through all the elements of an array...
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_for_loops.asp
Python For Loops
The for loop does not require an indexing variable to set beforehand. Even strings are iterable objects, they contain a sequence of characters:
๐ŸŒ
PragmaticLinux
pragmaticlinux.com โ€บ home โ€บ how to create an array of strings in python
How to create an array of strings in Python - PragmaticLinux
September 27, 2022 - This article explains how to create an array of strings in Python, including code examples for iterating over the string array.
๐ŸŒ
StudySmarter
studysmarter.co.uk โ€บ for loop in python
for Loop in Python: Syntax & Range | StudySmarter
A for loop in Python is a control flow statement used to iterate over a sequence (such as a list, tuple, dictionary, string, or range) and execute a block of code for each item in that sequence. It provides a simple way to automate repetitive tasks like traversing elements, processing data, or generating numbers with the `range()` function.
Find elsewhere
๐ŸŒ
Team Treehouse
teamtreehouse.com โ€บ community โ€บ loop-through-an-array-of-strings
Loop through an array of strings (Example) | Treehouse Community
November 20, 2015 - I have then appended those 3 variables to an array, and tried this method: for string in strings { string = "" } I get an error saying string is a constant. I then change my code to for var string in strings...
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ python โ€บ how to iterate a string in python using for loop
How to Iterate a String in Python using For Loop - Spark By {Examples}
May 21, 2024 - Following are quick examples of how to iterate a string using for loop. # Quick Examples of iterate string using for loop.
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ python โ€บ python_loop_arrays.htm
Python - Loop Arrays
import array as arr # creating array a = arr.array('i', [96, 26, 56, 76, 46]) # checking the length l = len(a) # loop variable idx = 0 # while loop while idx < l: print (a[idx]) # incrementing the while loop idx+=1 ยท On executing the above ...
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ python โ€บ python iterate over an array
Python Iterate Over an Array - Spark By {Examples}
May 31, 2024 - # Iterate by getting index and value for index, value in np.ndenumerate(arr): print(index, value) Yields below output. ... If you have a multi-dimensional array you need to perform multiple loops, to overcome this problem use nditer function of the NumPy module in Python.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ iterate-over-characters-of-a-string-in-python
Iterate over characters of a string in Python - GeeksforGeeks
July 11, 2025 - Explanation: for char in s: This line loops through the string s, with char representing each character in s one by one. If we need both the character and its index then enumerate() is a great choice.
๐ŸŒ
Dot Net Perls
dotnetperls.com โ€บ for-python
Python - for: Loop Over String Characters - Dot Net Perls
s = "abc" # Loop over string. for c in s: print(c) # Loop over string indexes.
๐ŸŒ
Quora
quora.com โ€บ How-do-I-create-an-array-for-loop-in-Python
How to create an array for loop in Python - Quora
Answer (1 of 3): If names is an array, you can loop to process it as such: for name in names: # do something # some other thing If you want to filter one list to create new list, use list comprehension. new names = [val for val in names if val != ...
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ for-loops-in-python
For Loops in Python
February 1, 2020 - For Loop Statements Python utilizes a for loop to iterate over a list of elements. Unlike C or Java, which use the for loop to change a value in steps and access something such as an array using that value. For loops iterate over collection based dat...
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ python โ€บ how to create array of strings in python
How to Create Array of Strings in Python - Spark By {Examples}
December 20, 2024 - # Iterate array of stings using for loop # get the strings for str in arr_str: print(str) # Output: # Spark # by # examples
๐ŸŒ
Real Python
realpython.com โ€บ python-for-loop
Python for Loops: The Pythonic Way โ€“ Real Python
3 weeks ago - Jane 25 Python Dev Canada >>> text = "abcde" >>> for character in text: ... print(character) ... a b c d e >>> for index in range(5): ... print(index) ... 0 1 2 3 4 ยท In these examples, you iterate over a tuple, string, and numeric range. Again, the loop traverses the sequence in the order of definition.
๐ŸŒ
Gitbooks
buzzcoder.gitbooks.io โ€บ codecraft-python โ€บ content โ€บ string โ€บ loop-through-a-string.html
Loop through a string ยท CodeCraft-Python - BuzzCoder
The len() function is a Python ... ยท Here we show two ways to iterate over characters in a string: One way to iterate over a string is to use for i in range(len(str)):. In this loop, the variable i receives the index so that each character can be accessed using str...
๐ŸŒ
Studytonight
studytonight.com โ€บ python โ€บ looping-in-python
Python Loops - for Loop and while Loop | Studytonight
In the first iteration, first element of the list name will be picked, i.e. "S", the next statement inside the for loop is continue, thus as soon as this keyword is found, the execution of rest of the for loop statements is skipped and the flow gets back to the for loop starting to get the next element and check the condition. Same steps are followed by the next element of our string, i.e., "t" and the continue interrupts the flow again, and this will happen everytime the execution flow reaches the continue keyqord.