Your code, as written, is close:

opnDays = ["mon", "tue", "wed", "thr", "fri"]

price = 10

def discount(array):
    disPrice = price
    for day in array:
        disPrice *= 0.9
        print(day, disPrice)

What I did here was change how disPrice was set on your loop. You were setting it to the same value (0.9 * price) on every iteration. All I did was set it to price in the beginning and multiply it by 0.9 every iteration, resulting in the desired behavior.

Answer from Woody1193 on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ gloss_python_array_loop.asp
Python Loop Through an Array
Python Examples Python Compiler ... Study Plan Python Interview Q&A Python Training ... You can use the for in loop to loop through all the elements of an array....
๐ŸŒ
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....
Discussions

Why iterate over an array using the index?
You do it if there is something in your loop that will use an index rather than the elements of the array. For instance, sometimes you want to sample something from another array that is not your loop array A cleaner way to do it is by using enumerate function for i, item in enumerate(array): The index gets assigned to i and whatever element of the array gets assigned to item. This may also be a bad habit from Matlab, people that come from Matlab are more used to looping over indexes. More on reddit.com
๐ŸŒ r/learnpython
57
46
April 22, 2023
How can I loop through an array forward and then backwards and then forwards and... etc with the modulus operator?
Given `n` is 1 less than the length of your array, you can increment and modulus some rotating index `i` against double `n` and then subtract `n`, take the absolute value and you get a bouncing number. It should be noted that you don't need to use any flags as suggested in other comments, but you do lose readability. Explanation: Take your example for an array of length 5, then `n=4`, `i` will rotate through values `[0, 1, 2, 3, 4, 5, 6, 7]` and subtracting `n` from each we get `[-4, -3, -2, -1, 0, 1, 2, 3]`, and the absolute values become `[4, 3, 2, 1, 0, 1, 2, 3]` which you can use to access the values at an index in your array. Try the following code: arr = [1, 2, 3, 4, 5] n = len(arr) - 1 i = n while True: curr_index = abs(i - n) print(arr[curr_index]) i = (i + 1) % (2 * n) and you will get output that looks like: 1 2 3 4 5 4 3 2 1 2 3 4 ... More on reddit.com
๐ŸŒ r/learnpython
5
1
September 9, 2021
Storing arrays in Python for loop - Stack Overflow
Let's say I have a function (called numpyarrayfunction) that outputs an array every time I run it. I would like to run the function multiple times and store the resulting arrays. Obviously, the cur... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Loop over an an array of array
I have an array of arrays I want to loop over to return two arrays called hills and valleys. When looping through each element, we check the item at index 1 that is element[0] if the value is equal to zero, we create another array and push the value inside. we keep a trace of it still when ... More on discuss.python.org
๐ŸŒ discuss.python.org
5
0
November 28, 2023
๐ŸŒ
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.
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ python โ€บ python iterate over an array
Python Iterate Over an Array - Spark By {Examples}
May 31, 2024 - How to use for loop to iterate over an array in Python? Iterate over an array is also referred to as looping through all the elements of an array which
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ numpy โ€บ numpy_array_iterating.asp
NumPy Array Iterating
It solves some basic issues which we face in iteration, lets go through it with examples. In basic for loops, iterating through each scalar of an array we need to use n for loops which can be difficult to write for arrays with very high ...
Find elsewhere
๐ŸŒ
Sololearn
sololearn.com โ€บ en โ€บ Discuss โ€บ 1684765 โ€บ python-array-for-loop
Python array for loop | Sololearn: Learn to code for FREE!
A for loop runs over the primary elements of a container. So if you wrote: for x in arr: x would be first a tuple of three, then a tuple of two, since that are the primary elements. x, *y now 'unpacks' that primary element, so that you can use ...
๐ŸŒ
CodeRivers
coderivers.org โ€บ blog โ€บ python-for-loop-array
Python For Loop with Arrays: A Comprehensive Guide - CodeRivers
February 22, 2026 - 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 ...
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ stable โ€บ reference โ€บ arrays.nditer.html
Iterating over arrays โ€” NumPy v2.5 Manual
The iterator object nditer, introduced in NumPy 1.6, provides many flexible ways to visit all the elements of one or more arrays in a systematic fashion. This page introduces some basic ways to use the object for computations on arrays in Python, then concludes with how one can accelerate the inner loop in Cython.
๐ŸŒ
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 != โ€˜ 'โ€™] This will create a new list...
๐ŸŒ
Dataquest
dataquest.io โ€บ home โ€บ blog โ€บ tutorial: advanced python for loops
Tutorial: Advanced Python for Loops
March 11, 2025 - In the code below, we'll write a for loop that iterates through each element by passing z, our two-dimensional array, as the argument for nditer(): ... As we can see, this first lists all of the elements in x, then all elements of y. Remember! When looping through these different data structures, dictionaries require a method, NumPy arrays require a function. When we're working with data in Python, we're often using pandas DataFrames.
๐ŸŒ
CodeRivers
coderivers.org โ€บ blog โ€บ python-looping-through-array
Python Looping Through Arrays: A Comprehensive Guide - CodeRivers
July 21, 2026 - The zip function combines the elements from the two arrays into tuples, and the for loop unpacks these tuples into element1 and element2 in each iteration. List comprehensions provide a concise, Pythonic way to create new lists by transforming or filtering elements from an existing iterable.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ iterate-over-a-list-in-python
Iterate Over a List in Python - GeeksforGeeks
Explanation: loop starts from index 0, prints the element at the current index, increments the index, and continues until all elements have been processed. range() function can be combined with a for loop to iterate through the indices of a list.
Published: July 16, 2026
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ how can i loop through an array forward and then backwards and then forwards and... etc with the modulus operator?
r/learnpython on Reddit: How can I loop through an array forward and then backwards and then forwards and... etc with the modulus operator?
September 9, 2021 -

Say I have an array:

arr = [1,2,3,4,5]

and I want to output this using a simple counter and the modulus operator

1 
2
3
4 
5 
4
3 
2
1 
2 
3 
4 
5 
... 

Is this possible? I know that you can loop through an array and start over at the beginning by doing

arr[count % len(arr)]

but how do I just switch directions instead of going back to the beginning?

๐ŸŒ
Python.org
discuss.python.org โ€บ python help
Loop over an an array of array - Python Help - Discussions on Python.org
November 28, 2023 - I have an array of arrays I want to loop over to return two arrays called hills and valleys. When looping through each element, we check the item at index 1 that is element[0] if the value is equal to zero, we create another array and push the value inside. we keep a trace of it still when we meet another element where the element[0] is greater than zero then the trace breaks after that we push what is in the array to the valley array and the same thing goes for hills.
๐ŸŒ
DataCamp
campus.datacamp.com โ€บ courses โ€บ intermediate-python โ€บ loops
Loop over NumPy array - Intermediate Python
Two NumPy arrays that you might recognize from the intro course are available in your Python session: np_height, a NumPy array containing the heights of Major League Baseball players, and np_baseball, a 2D NumPy array that contains both the heights (first column) and weights (second column) of those players. ... Import the numpy package under the local alias np. Write a for loop that iterates over all elements in np_height and prints out "x inches" for each element, where x is the value in the array.
๐ŸŒ
HCL GUVI
studytonight.com โ€บ python โ€บ looping-in-python
HCL GUVI | Learn to code in your native language
HCL GUVI IDE is an Integrated Development Environment (IDE) for coding. Allows you to write, edit, run, test, and debug your code. Comes with a built-in debugger to fix code errors. Supports JavaScript, Python, Ruby, and 20+ programming languages.Explore IDE