A PHP Error was encountered

Severity: Warning

Message: fopen(/tmp/ci_sessiontksetc3p03f6parhi1se7agm1b27sgk0): failed to open stream: No space left on device

Filename: drivers/Session_files_driver.php

Line Number: 176

Backtrace:

File: /var/www/html/application/controllers/Project.php
Line: 10
Function: __construct

File: /var/www/html/index.php
Line: 311
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: session_start(): Failed to read session data: user (path: /tmp)

Filename: Session/Session.php

Line Number: 143

Backtrace:

File: /var/www/html/application/controllers/Project.php
Line: 10
Function: __construct

File: /var/www/html/index.php
Line: 311
Function: require_once

Reversing an array in Python | Suchitra
Coders Packet

Reversing an array in Python

By YANIGANTI SUCHITRA

In this program, we get a little awareness regarding reversing an array in Python. We are reversing an array using for loop although, we have different methods to solve this program.

Reversing an array in Python program    

              This program describes the reversing of an array. We can solve reversing an array in different methods like for loop, reverse() method, reversed() method, using slicing, using recursion, using swapping and so on. In this program, we are using for loop. First, we will initialize an array named s and considering our convenient array elements here, we are using array elements as [1,2,3,4,5]. After, this we are using for loop range of 0 to the length of an array and printing the array.

              Again, we are considering for loop with the length of an array with a decremented length of 1 and printing the array of elements in each iteration. For example, if an original array is [2,4,6,8] we obtain the reversing array as [8,6,4,2]. The Python language does not support array data structure. Instead, it has in-built list structures that are easy to use. There are many user-defined and in-built methods in Python to reverse an array. An array is a data structure that is used to store homogeneous elements in order and stored elements are identified by an index value or a key.

      Output

Download Complete Code

Comments

No comments yet

Download Packet

Reviews Report

Submitted by YANIGANTI SUCHITRA (Suchitra)

Download packets of source code on Coders Packet