Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Python program to convert an array to an ordinary list with the same items
The array is given. Our task is to convert an array to an ordinary list. We solve this problem with the help of tolist() function. This function return the array as a (possibly nested) list.
Algorithm
Step 1: Given an array. Step 2: convert the array to a list using tolist() function. Step 3: Display list
Example Code
#Python program to convert an array to an ordinary
#list with the same items
from array import *
def arraytolist(A):
lst = A.tolist() # list
print("The List Is ::>",lst)
# Driver code
A= array('i', [20,30,60]) # array
arraytolist(A)
Output
The List Is ::> [20, 30, 60] The List Is ::> [20, 30, 60]
Advertisements
