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
🌐
W3Schools
w3schools.com › python › gloss_python_array_loop.asp
Python Loop Through an Array
Remove List Duplicates Reverse ... Bootcamp Python Certificate Python Training ... You can use the for in loop to loop through all the elements of an array......
Discussions

How to loop through array of strings Python - Stack Overflow
Because without splitting, for word in text assigns word to each character in text. Presumably you want to delete whole words, not just any character that happens to appear in that word. But why ask here; why not try it and see what happens? ... When we iterate over a string of text, why do we get individual letters not words ? The Zen of Python ... More on stackoverflow.com
🌐 stackoverflow.com
September 4, 2014
I want to create a loop that will make new arrays for strings of text in a file using indexing (or whatever works). Best way to approach?
Anytime you think you need unique names for multiple objects you almost certainly should put those objects into a list. From what you have said maybe you can use the readlines() function to read your data from the file. That should do most of what you want. If your file contains these lines: alpha beta gamma then this code: with open("the_file") as fd: data = fd.readlines() print(data) would print ['alpha\n', 'beta\n', 'gamma\n']. More on reddit.com
🌐 r/learnpython
10
1
July 17, 2022
Loop through an array of strings
Simen Anthonsen is having issues with: Does someone know how you can loop through an array of strings, and set each string to an empty string? In my app have created 3 variabl... More on teamtreehouse.com
🌐 teamtreehouse.com
1
November 20, 2015
Python loop through array and add to initial array
Hello! I was working on this exercise: https://www.codecademy.com/courses/learn-python-3/lessons/create-python-list/exercises/append-list And I have a question. It may be dumb 🙂 Why does def add_order(new_orders): orders = ["daisies", "periwinkle"] for x in new_orders: orders.append(x) return ... More on discuss.codecademy.com
🌐 discuss.codecademy.com
0
0
April 6, 2023
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
🌐
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
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python iterate over an array
Python Iterate Over an Array - Spark By {Examples}
May 31, 2024 - In order to use arrays in Python you have to use the NumPy library, and this library also provides methods nditer(), ndenumerate() to loop through single and multi-dimensional arrays.
Find elsewhere
🌐
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, ...
🌐
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 - Python String datatype support ... parsing and extracting information from strings. You can use for loop to iterate over a string and get each character of the string....
🌐
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.
🌐
W3Schools
w3schools.com › python › python_for_loops.asp
Python For Loops
Remove List Duplicates Reverse ... Interview Q&A Python Bootcamp Python Certificate Python Training ... A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a stri...
🌐
Tutorialspoint
tutorialspoint.com › python › python_loop_arrays.htm
Python - Loop Arrays
import array as arr # creating ... of array with built-in len() function. Use it to create a range object to get the series of indices and then access the array elements in a for loop....
🌐
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.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-for-loops
Python For Loops - GeeksforGeeks
Python for loops are used for iterating over sequences like lists, tuples, strings and ranges.
Published   5 days ago
🌐
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... The error goes away, but it does´t work ... When you made the loop for string in strings the 'string' value is actually a copy of the element in the array.
🌐
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.
🌐
Codecademy Forums
discuss.codecademy.com › computer science
Python loop through array and add to initial array - Computer Science - Codecademy Forums
April 6, 2023 - Hello! I was working on this exercise: https://www.codecademy.com/courses/learn-python-3/lessons/create-python-list/exercises/append-list And I have a question. It may be dumb 🙂 Why does def add_order(new_orders): orders = ["daisies", "periwinkle"] for x in new_orders: orders.append(x) return orders print(add_order(['tulips'])) print(add_order(['roses'])) return ['daisies', 'periwinkle', 'tulips'] ['daisies', 'periwinkle', 'roses'] I heard that .append generally ...
🌐
CodeRivers
coderivers.org › blog › python-for-loop-array
Python For Loop with Arrays: A Comprehensive Guide - CodeRivers
April 5, 2025 - The for loop in Python is used to iterate over a sequence (like a list, tuple, string, etc.). The basic syntax is: for variable in sequence: # code block to be executed print(variable) Here, the variable takes on each value in the sequence one by one, and the code block inside the loop is executed ...
🌐
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...