About 50 results
Open links in new tab
  1. python - Iterating through array - Stack Overflow

    Oct 31, 2015 · 3 If you want to stay with a for-loop (e.g. because you want to mutate the existing array instead of creating a new one), you should simplify the code. I would first simplify the …

  2. python - How can I access the index value in a 'for' loop? - Stack …

    168 Tested on Python 3.12 Here are twelve examples of how you can access the indices with their corresponding array's elements using for loops, while loops and some looping functions. …

  3. Assign values to array during loop - Python - Stack Overflow

    Feb 19, 2017 · I would like to write a loop in Python, where the size of the array increases with every iteration (i.e., I can assign a newly calculated value to a different index of a variable). For …

  4. Python 'For' Loop Iterate Array - Stack Overflow

    I am new to python and I am looking for some help with loop structures, specifically how to use a 'For' loop or alternative loop to solve a problem. I need to figure a discounted price based on …

  5. Iterating through a for loop with the size of an array

    Dec 10, 2022 · 0 Create Array with input number (Eg. arr = [12, 15, 4] ) Iterate over the created Array In for loop check if number are divisible by 3 and 5 Sample code:

  6. How to modify list entries during for loop? - Stack Overflow

    Sep 8, 2023 · 0 In this example, the objective is to, using a Python 'for' loop, REMOVE from an array of integers any element that is perfectly divisible by 7:

  7. Iterating through a multidimensional array in Python

    Jun 9, 2009 · I have created a multidimensional array in Python like this: self.cells = np.empty((r,c),dtype=np.object) Now I want to iterate through all elements of my …

  8. python - Looping through Numpy Array elements - Stack Overflow

    May 31, 2020 · Is there a more readable way to code a loop in Python that goes through each element of a Numpy array? I have come up with the following code, but it seems cumbersome …

  9. iteration - How to loop backwards in python? - Stack Overflow

    How to loop backwards in python? [duplicate] Asked 15 years, 6 months ago Modified 7 years, 5 months ago Viewed 780k times

  10. python - loop through array or list in variable steps - Stack Overflow

    Feb 5, 2019 · Don't use a for loop. for loops in python are different than in C or Java. In those languages, a for loop has an initial condition, a termination condition, and an increment for …