How to Reverse an Array in Python: 6 Practical Ways

When I build reporting scripts, I often receive records in oldest-to-newest order. Reversing the array lets me process the latest transactions, log entries, or sensor readings first.

You can reverse an array in Python with slicing, reverse(), reversed(), a loop, the array module, or NumPy. The right option depends on whether you need a new array or want to modify the original one.

This guide walks through six practical approaches and explains when each one works best.

What Does Reversing an Array Mean in Python?

Reversing an array changes the order of its elements without changing their values.

Consider this list of daily order totals:

order_totals = [120, 185, 240, 310]

After reversing it, the values appear from last to first:

[310, 240, 185, 120]

Python developers often use a list when they need an array-like collection. Lists can store numbers, strings, objects, or mixed data types. You can learn more about the available options in this guide to creating arrays in Python.

Python also provides the built-in array module for typed numeric values. Data analysis projects commonly use a NumPy array, which offers fast numerical operations.

How to Reverse an Array in Python with Slicing

Slicing extracts part of a sequence using the following syntax:

sequence[start:stop:step]

A step value of -1 tells Python to move backward through the sequence.

order_ids = [101, 102, 103, 104, 105]

reversed_order_ids = order_ids[::-1]

print(reversed_order_ids)
print(order_ids)

Output:

[105, 104, 103, 102, 101]
[101, 102, 103, 104, 105]

I executed the above example code and added the screenshot below.

Reverse an Array in Python

The expression order_ids[::-1] starts at the end and moves toward the beginning. It creates a new list, so the original data remains unchanged.

I use this approach when an automation script needs both versions. For example, a report may display recent orders first while another calculation still depends on the original sequence.

If slicing syntax feels unfamiliar, this detailed guide to slicing lists in Python explains start, stop, and step values.

Pro Tip: In my experience, slicing works best for small and medium lists. Remember that it creates a full copy, which increases memory usage for very large datasets.

Reverse an Array in Python with reverse()

The list reverse() method changes the original list directly. This behavior is called an in-place operation because Python does not create another list.

log_levels = ["INFO", "WARNING", "ERROR", "CRITICAL"]

log_levels.reverse()

print(log_levels)

Output:

['CRITICAL', 'ERROR', 'WARNING', 'INFO']

I executed the above example code and added the screenshot below.

How to Reverse an Array in Python

Use reverse() when you no longer need the original order. It provides a clear and memory-efficient solution because it rearranges the existing elements.

A common mistake involves assigning its result to another variable:

log_levels = ["INFO", "WARNING", "ERROR"]

result = log_levels.reverse()

print(result)

Output:

None

The method returns None because its job is to update the existing list. Use the list variable after calling the method:

log_levels.reverse()
print(log_levels)

For more examples of this behavior, see the complete guide to the Python list reverse method.

Reverse an Array with the reversed() Function

The built-in reversed() function reads a sequence from the last element to the first. It returns an iterator, which produces one value at a time instead of creating a complete list immediately.

response_times = [210, 185, 240, 175]

reversed_values = reversed(response_times)

for response_time in reversed_values:
print(response_time)

Output:

175
240
185
210

This approach works well when you only need to loop through the data backward. It avoids making a full copy of the list.

Convert the iterator to a list when you need to store or reuse the reversed result:

response_times = [210, 185, 240, 175]

reversed_response_times = list(reversed(response_times))

print(reversed_response_times)

Output:

[175, 240, 185, 210]

I executed the above example code and added the screenshot below.

Reverse an Python Array

The original response_times list stays unchanged. This technique also works with tuples, strings, and other reversible sequences.

If your main goal is processing rather than creating another collection, review these examples for iterating through a list backward in Python.

Reverse an Array in Python Using a Loop

A manual loop helps beginners understand how array reversal works internally. It also gives you room to transform or validate each value during reversal.

temperatures = [22, 24, 23, 26]
reversed_temperatures = []

for index in range(len(temperatures) - 1, -1, -1):
reversed_temperatures.append(temperatures[index])

print(reversed_temperatures)

Output:

[26, 23, 24, 22]

The range() function starts at the final index. It stops before -1 and moves backward one position at a time.

Here is what its three arguments mean:

  • len(temperatures) - 1 identifies the last valid index.
  • -1 sets the exclusive stopping point.
  • The final -1 makes the loop move backward.

A loop becomes useful when each element needs extra processing:

prices = [125.50, 80.00, 210.25]
reversed_rounded_prices = []

for index in range(len(prices) - 1, -1, -1):
reversed_rounded_prices.append(round(prices[index]))

print(reversed_rounded_prices)

Output:

[210, 80, 126]

The script reverses and rounds each price in one pass. For basic reversal alone, slicing or reverse() remains shorter and easier to maintain.

You can explore similar iteration patterns in this guide to looping through a Python list.

Reverse an Array Created with the array Module

Python’s built-in array module stores values of one data type. A type code tells Python what kind of values the array accepts.

from array import array

stock_counts = array("i", [15, 20, 12, 30])

stock_counts.reverse()

print(stock_counts.tolist())

Output:

[30, 12, 20, 15]

The "i" type code represents signed integers. The reverse() method modifies the original array, just like a list’s reverse() method.

You can also use slicing when you need a separate array:

from array import array

stock_counts = array("i", [15, 20, 12, 30])
reversed_stock_counts = stock_counts[::-1]

print(reversed_stock_counts.tolist())

Output:

[30, 12, 20, 15]

Use the array module when you need a lightweight typed collection without installing another package. If your data starts as a list, follow these steps to convert a list to an array in Python.

Reverse a NumPy Array in Python

NumPy is a Python package designed for fast numerical calculations. It supports one-dimensional and multidimensional arrays.

For a one-dimensional NumPy array, use slicing:

import numpy as np

sales = np.array([450, 520, 610, 580])
reversed_sales = sales[::-1]

print(reversed_sales)

Output:

[580 610 520 450]

You can also use np.flip():

import numpy as np

sales = np.array([450, 520, 610, 580])
reversed_sales = np.flip(sales)

print(reversed_sales)

Output:

[580 610 520 450]

np.flip() clearly communicates the operation and becomes especially helpful with multidimensional data.

Consider this two-dimensional array:

import numpy as np

monthly_sales = np.array([
[120, 140, 160],
[180, 200, 220]
])

reversed_rows = np.flip(monthly_sales, axis=0)
reversed_columns = np.flip(monthly_sales, axis=1)

print(reversed_rows)
print(reversed_columns)

Output:

[[180 200 220]
[120 140 160]]

[[160 140 120]
[220 200 180]]

axis=0 reverses the row order. axis=1 reverses the values inside each row.

For additional array operations, read this introduction to Python NumPy arrays and these examples of reversing a NumPy array.

Which Array Reversal Method Should You Use?

Choose the method based on how your script uses the data:

RequirementRecommended approach
Create a reversed listitems[::-1]
Change the original listitems.reverse()
Process values backwardreversed(items)
Transform values while reversingManual loop
Reverse a typed Python arrayarray.reverse()
Reverse numerical or multidimensional datanp.flip()

For most beginner Python scripts, slicing offers the simplest solution. Use reverse() when memory matters and changing the original order causes no problems.

Things to Keep in Mind

  • Original data: Slicing and list(reversed(...)) create new collections. The reverse() method changes the original collection.
  • Return value: reverse() returns None. Do not assign its result to a variable.
  • Memory usage: Slicing creates a copy. Prefer reversed() when processing a large sequence one item at a time.
  • Iterator consumption: A reversed() iterator produces each value once. Convert it to a list if you need repeated access.
  • Index boundaries: Manual loops must start at len(array) - 1. Starting at len(array) causes an IndexError.
  • NumPy axes: Choose the correct axis when reversing multidimensional arrays. The wrong axis changes a different dimension.

Frequently Asked Questions

What is the easiest way to reverse an array in Python?

Use slicing with array[::-1]. It creates a reversed copy and keeps the original array unchanged.

Does reverse() create a new array in Python?

No. The reverse() method changes the existing list or array object in place and returns None.

What is the difference between reverse() and reversed()?

reverse() modifies the original collection. reversed() returns an iterator and leaves the original collection unchanged.

How do I reverse an array without using reverse()?

Use slicing with array[::-1], the built-in reversed() function, or a backward loop. Slicing provides the shortest option for a list.

How do I reverse only part of an array in Python?

Use slice assignment to replace a selected section with its reversed version:
numbers = [10, 20, 30, 40, 50] numbers[1:4] = numbers[1:4][::-1] print(numbers)
The result is [10, 40, 30, 20, 50].

How do I reverse a two-dimensional NumPy array?

Use np.flip(array, axis=0) to reverse rows or np.flip(array, axis=1) to reverse columns. Use np.flip(array) without an axis to reverse every dimension.

You can reverse Python arrays with slicing, reverse(), reversed(), loops, the array module, or NumPy. Start with slicing for a clean copy, then choose another method when memory, data type, or multidimensional structure matters. I hope this practical guide helps you choose the right approach for your next Python script.

You May Also Like

51 Python Programs

51 PYTHON PROGRAMS PDF FREE

Download a FREE PDF (112 Pages) Containing 51 Useful Python Programs.

pyython developer roadmap

Aspiring to be a Python developer?

Download a FREE PDF on how to become a Python developer.

Let’s be friends

Be the first to know about sales and special discounts.