Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python
communitycreator

What is the array reverse() method in Python?

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Answers Code

Overview

An array in python is used to store multiple values of the same datatype in a single variable.

The reverse() function is simply used to reverse the order of the items in a given array.

Syntax

array.reverse()

Parameter value

The reverse() method takes no parameter value.

Return value

The reverse() function returns the reversed array as an output.

Example

# importing the array module
import array as arr
# creating an integer data type array
x = arr.array('i', [1,2,3,4,5,6,7])
# reversing the arraay using the reverse method
x.reverse()
# Printing the reversed array
print(x)
Example: reverse array

RELATED TAGS

python
communitycreator

CONTRIBUTOR

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Answers Code
Keep Exploring