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:
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.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/python-exercises/data-structures-and-algorithms/python-data-structure-exercise-16.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics