w3resource

Python Data Structure: Convert an array to an ordinary list with the same items

Python Data Structure: Exercise-10 with Solution

Write a Python program to convert an array to an ordinary list with the same items.

Sample Solution:

Python Code:

from array import array
arra1 = array('b', [1,2,3,4])
print("Original array: ")
print(arra1)
print("Array to list: ")
print(arra1.tolist())

Sample Output:

Original array:                                                                                               
array('b', [1, 2, 3, 4])                                                                                      
Array to list:                                                                                                
[1, 2, 3, 4] 

Flowchart:

Flowchart: Convert an array to an ordinary list with the same items

Python Code Editor:

Contribute your code and comments through Disqus.

Previous: Write a Python program to get the length of an array.
Next: Write a Python program to convert an array to an array of machine values and return the bytes representation.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.