Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python Write a program to reverse an array or string

# Iterative python program to reverse an array
 
# Function to reverse A[] from start to end
def reverseList(A, start, end):
    while start < end:
        A[start], A[end] = A[end], A[start]
        start += 1
        end -= 1
 
# Driver function to test above function
A = [1, 2, 3, 4, 5, 6]
print(A)
reverseList(A, 0, 5)
print("Reversed list is")
print(A)
Comment

PREVIOUS NEXT
Code Example
Python :: How to subtract all the numbers in a list from the first number? 
Python :: Calculate summary statistics across columns 
Python :: numpy retrieve 5 highest value index 
Python :: if len formula applied to a column python 
Python :: get column means pandas 
Python :: palindrome program in python 
Python :: Class based Django rest framework 
Python :: valueerror python list 
Python :: how to strip characters in python 
Python :: running setup.py install for rjsmin ... error 
Python :: how to open cmd as administrator with python 
Python :: Sampling data in different ways 
Python :: Lightbank b2c 
Python :: how i make viribal inside a string in python 
Python :: Implementing Java-style getters and setters in Python 
Python :: stackoverflow Django ForeignKey 
Python :: python two list into dictinaray 
Python :: how to filter even or odd model id in django 
Python :: upper method in python 
Python :: transform jpg image into array for conv2d 
Python :: how to run ewa requirement.txt file 
Python :: pygame kreis definition 
Python :: RuntimeError: input must have 3 dimensions, got 4 site:stackoverflow.com 
Python :: save gif python 
Python :: python numpy read from stdin 
Python :: dashes in python packages 
Python :: To install the C++ and Python Messaging APIs: 
Python :: Python Getting back to Decorators 
Python :: Get Today’s Year, Month, and Date using today method 
Python :: iterate over the dataset and compute the mean vector. 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =